Method for Class-Based Update Block Replacement Rules in Non-Volatile Memory

ABSTRACT

In a nonvolatile memory with block management system, data are written to blocks and are erasable block by block. At any time a pool of blocks are open for storing data concurrently. The number of blocks in the pool is limited. A replacement system allows new blocks to be introduced into the pool without exceeding the limit. In particular, different classes of blocks in the pool each has its own replacement rule, such as closing a least active block before being replaced. In this way, possible inefficiency and premature closure of blocks in the pool can be avoided.

CROSS REFERENCE TO RELATED APPLICATION

This application is also related to the following U.S. patentapplication: U.S. application Ser. No. ______, entitled “Non-VolatileMemory With Class-Based Update Block Replacement Rules,” by Jason T.Lin, filed concurrently herewith, on Sep. 15, 2006.

FIELD OF THE INVENTION

This invention relates generally to non-volatile semiconductor memoryand specifically to those having a memory block management system withan improved system for managing replacement of a pool of blocks openconcurrently for storing data.

BACKGROUND OF THE INVENTION

Solid-state memory capable of nonvolatile storage of charge,particularly in the form of EEPROM and flash EEPROM packaged as a smallform factor card, has recently become the storage of choice in a varietyof mobile and handheld devices, notably information appliances andconsumer electronics products. Unlike RAM (random access memory) that isalso solid-state memory, flash memory is non-volatile, and retaining itsstored data even after power is turned off. Also, unlike ROM (read onlymemory), flash memory is rewritable similar to a disk storage device. Inspite of the higher cost, flash memory is increasingly being used inmass storage applications. Conventional mass storage, based on rotatingmagnetic medium such as hard drives and floppy disks, is unsuitable forthe mobile and handheld environment. This is because disk drives tend tobe bulky, are prone to mechanical failure and have high latency and highpower requirements. These undesirable attributes make disk-based storageimpractical in most mobile and portable applications. On the other hand,flash memory, both embedded and in the form of a removable card isideally suited in the mobile and handheld environment because of itssmall size, low power consumption, high speed and high reliabilityfeatures.

Flash EEPROM is similar to EEPROM (electrically erasable andprogrammable read-only memory) in that it is a non-volatile memory thatcan be erased and have new data written or “programmed” into theirmemory cells. Both utilize a floating (unconnected) conductive gate, ina field effect transistor structure, positioned over a channel region ina semiconductor substrate, between source and drain regions. A controlgate is then provided over the floating gate. The threshold voltagecharacteristic of the transistor is controlled by the amount of chargethat is retained on the floating gate. That is, for a given level ofcharge on the floating gate, there is a corresponding voltage(threshold) that must be applied to the control gate before thetransistor is turned “on” to permit conduction between its source anddrain regions. In particular, flash memory such as Flash EEPROM allowsentire blocks of memory cells to be erased at the same time.

The floating gate can hold a range of charges and therefore can beprogrammed to any threshold voltage level within a threshold voltagewindow. The size of the threshold voltage window is delimited by theminimum and maximum threshold levels of the device, which in turncorrespond to the range of the charges that can be programmed onto thefloating gate. The threshold window generally depends on the memorydevice's characteristics, operating conditions and history. Eachdistinct, resolvable threshold voltage level range within the windowmay, in principle, be used to designate a definite memory state of thecell. When the threshold voltage is partitioned into two distinctregions, each memory cell will be able to store one bit of data.Similarly, when the threshold voltage window is partitioned into morethan two distinct regions, each memory cell will be able to store morethan one bit of data.

The transistor serving as a memory cell is typically programmed to a“programmed” state by one of two mechanisms. In “hot electroninjection,” a high voltage applied to the drain accelerates electronsacross the substrate channel region. At the same time a high voltageapplied to the control gate pulls the hot electrons through a thin gatedielectric onto the floating gate. In “tunneling injection,” a highvoltage is applied to the control gate relative to the substrate. Inthis way, electrons are pulled from the substrate to the interveningfloating gate. While the term “program” has been used historically todescribe writing to a memory by injecting electrons to an initiallyerased charge storage unit of the memory cell so as to alter the memorystate, it has now been used interchangeable with more common terms suchas “write” or “record.”

The memory device may be erased by a number of mechanisms. For EEPROM, amemory cell is electrically erasable, by applying a high voltage to thesubstrate relative to the control gate so as to induce electrons in thefloating gate to tunnel through a thin oxide to the substrate channelregion (i.e., Fowler-Nordheim tunneling.) Typically, the EEPROM iserasable byte by byte. For flash EEPROM, the memory is electricallyerasable either all at once or one or more minimum erasable blocks at atime, where a minimum erasable block may consist of one or more sectorsand each sector may store 512 bytes or more of data.

The memory device typically comprises one or more memory chips that maybe mounted on a card. Each memory chip comprises an array of memorycells supported by peripheral circuits such as decoders and erase, writeand read circuits. The more sophisticated memory devices also come witha controller that performs intelligent and higher level memoryoperations and interfacing.

There are many commercially successful non-volatile solid-state memorydevices being used today. These memory devices may be flash EEPROM ormay employ other types of nonvolatile memory cells. Examples of flashmemory and systems and methods of manufacturing them are given in U.S.Pat. Nos. 5,070,032, 5,095,344, 5,315,541, 5,343,063, and 5,661,053,5,313,421 and 6,222,762. In particular, flash memory devices with NANDstring structures are described in U.S. Pat. Nos. 5,570,315, 5,903,495,6,046,935. Also nonvolatile memory devices are also manufactured frommemory cells with a dielectric layer for storing charge. Instead of theconductive floating gate elements described earlier, a dielectric layeris used. Such memory devices utilizing dielectric storage element havebeen described by Eitan et al., “NROM: A Novel Localized Trapping, 2-BitNonvolatile Memory Cell,” IEEE Electron Device Letters, vol. 21, no. 11,November 2000, pp. 543-545. An ONO dielectric layer extends across thechannel between source and drain diffusions. The charge for one data bitis localized in the dielectric layer adjacent to the drain, and thecharge for the other data bit is localized in the dielectric layeradjacent to the source. For example, U.S. Pat. Nos. 5,768,192 and6,011,725 disclose a nonvolatile memory cell having a trappingdielectric sandwiched between two silicon dioxide layers. Multi-statedata storage is implemented by separately reading the binary states ofthe spatially separated charge storage regions within the dielectric.

In order to improve read and program performance, multiple chargestorage elements or memory transistors in an array are read orprogrammed in parallel. Thus, a “page” of memory elements are read orprogrammed together. In existing memory architectures, a row typicallycontains several interleaved pages or it may constitute one page. Allmemory elements of a page will be read or programmed together.

In flash memory systems, erase operation may take as much as an order ofmagnitude longer than read and program operations. Thus, it is desirableto have the erase block of substantial size. In this way, the erase timeis amortized over a large aggregate of memory cells.

The nature of flash memory predicates that data must be written to anerased memory location. If data of a certain logical address from a hostis to be updated, one way is rewrite the update data in the samephysical memory location. That is, the logical to physical addressmapping is unchanged. However, this will mean the entire erase blockcontain that physical location will have to be first erased and thenrewritten with the updated data. This method of update is inefficient,as it requires an entire erase block to be erased and rewritten,especially if the data to be updated only occupies a small portion ofthe erase block. It will also result in a higher frequency of eraserecycling of the memory block, which is undesirable in view of thelimited endurance of this type of memory device.

Another problem with managing flash memory system has to do with systemcontrol and directory data. The data is produced and accessed during thecourse of various memory operations. Thus, its efficient handling andready access will directly impact performance. It would be desirable tomaintain this type of data in flash memory because flash memory is meantfor storage and is nonvolatile. However, with an intervening filemanagement system between the controller and the flash memory, the datacan not be accessed as directly. Also, system control and directory datatends to be active and fragmented, which is not conducive to storing ina system with large size block erase. Conventionally, this type of datais set up in the controller RAM, thereby allowing direct access by thecontroller. After the memory device is powered up, a process ofinitialization enables the flash memory to be scanned in order tocompile the necessary system control and directory information to beplaced in the controller RAM. This process takes time and requirescontroller RAM capacity, all the more so with ever increasing flashmemory capacity.

U.S. Pat. No. 6,567,307 discloses a method of dealing with sectorupdates among large erase block including recording the update data inmultiple erase blocks acting as scratch pad and eventually consolidatingthe valid sectors among the various blocks and rewriting the sectorsafter rearranging them in logically sequential order. In this way, ablock needs not be erased and rewritten at every slightest update.

W0 03/027828 and W0 00/49488 both disclose a memory system dealing withupdates among large erase block including partitioning the logicalsector addresses in zones. A small zone of logical address range isreserved for active system control data separate from another zone foruser data. In this way, manipulation of the system control data in itsown zone will not interact with the associated user data in anotherzone. Updates are at the logical sector level and a write pointer pointsto the corresponding physical sectors in a block to be written. Themapping information is buffered in RAM and eventually stored in a sectorallocation table in the main memory. The latest version of a logicalsector will obsolete all previous versions among existing blocks, whichbecome partially obsolete. Garbage collection is performed to keeppartially obsolete blocks to an acceptable number.

Prior art systems tend to have the update data distributed over manyblocks or the update data may render many existing blocks partiallyobsolete. The result often is a large amount of garbage collectionnecessary for the partially obsolete blocks, which is inefficient andcauses premature aging of the memory. Also, there is no systematic andefficient way of dealing with sequential update as compared tonon-sequential update.

Therefore there is a general need for high capacity and high performancenon-volatile memory. In particular, there is a need to have a highcapacity nonvolatile memory able to conduct memory operations in largeblocks without the aforementioned problems.

SUMMARY OF INVENTION

A non-volatile memory system is organized in physical groups of physicalmemory locations. Each physical group (metablock) is erasable as a unitand can be used to store a logical group of data. A memory managementsystem allows for update of a logical group of data by allocating ametablock dedicated to recording the update data of the logical group.The update metablock records update data in the order received and hasno restriction on whether the recording is in the correct logical orderas originally stored (sequential) or not (chaotic). Eventually theupdate metablock is closed to further recording. One of severalprocesses will take place, but will ultimately end up with a fullyfilled metablock in the correct order which replaces the originalmetablock. In the chaotic case, directory data is maintained in thenon-volatile memory in a manner that is conducive to frequent updates.The system supports multiple logical groups being updated concurrently.

One feature of the invention allows data to be updated logical-group bylogical-group. Thus, when a logical group is being updated, thedistribution of logical units (and also the scatter of memory units thatthe updates obsolete) are limited in range. This is especially true whenthe logical group is normally contained within a physical block.

During updates of the logical group, typically one or two blocks need beassigned to buffer the updated logical units. Thus, garbage collectionneed only be performed over a relatively fewer number of blocks. Garbagecollection of a chaotic block may be performed by either consolidationor compaction.

The economy of the update process is further evident in the generictreatment of the update blocks so that no additional block need beassigned for chaotic (non-sequential) updates as compared to thesequential ones. All update blocks are allocated as sequential updateblock, and any update block can change to a chaotic update block.Indeed, the change of an update block from sequential to chaotic isdiscretionary.

The efficient use of system resource allows multiple logical groups tobe updated concurrently. This further increases efficiency and reducesoverheads.

According to one aspect of the invention, in a nonvolatile memory with ablock management system, an improved block replacement scheme isimplemented for a system supporting up to a first predetermined maximumnumber of update blocks that are concurrently opened for recording data.The update blocks are mainly sequential update blocks where data arerecorded in logically sequential order but up to a second predeterminedmaximum number of which are allowed to be chaotic update blocks wheredata are not recorded in logically sequential order. Whenever a newallocation of an update block may cause the pool of update blocks toexceed either the first or second predetermined maximum number, one ofthe existing update blocks in the pool will be closed and removed inorder to comply with the limitation. Prior to closing the update block,its data are consolidated into a sequential block. The improved schemeis to avoid the situation where a sequential update can cause anexcessive number of chaotic block consolidations. This is accomplishedby separating sequential update blocks and chaotic update blocks intorespective replacement or consolation pools. In particular, when asequential update causes the allocation of a new update block to exceedthe first predetermined maximum number, a least recently used sequentialupdate block of the pool is preferentially to make room.

In the current system, generally there are two types of data: user dataand control data. The user data are sent from a host to the memorysystem typically in logical sequential order. Sequential update blocksare allocated to optimally handle sequential write operations from thehost. The user data can also be in logically non-sequential orderespecially when there are subsequent updates to the logical data.Chaotic update blocks are created to optimally handle the data innon-sequential order. Another source of chaotic or non-sequential datais control data maintained by the file system or the memory system suchas file and directory information which are generated in the course ofstoring user data.

Previous scheme of complying to a practical system limitation ofsupporting up to a maximum number of concurrently opened update blockshas been to close the least recently used update block in the pool,irrespective of whether it is sequential or chaotic.

The present scheme improves over the previous scheme where essentially,if during a sequential write operation an update block among a poolthereof needs to be closed to make room for a new allocation, the leastrecently used sequential update block in the pool is closed. Thisensures the various update blocks are effectively used to handlesequential write operations and random write operations. In particular,it avoids the inefficient situation where a large sequential writeoperation by the host may force a premature closure of a chaotic updateblock containing FAT and Directory information. Another chaotic blockwill in effect be created very soon to store the FAT and Directoryinformation which will be updated again once the large sequential writeoperation is done. The creation of the improved replacement policymandates separation of the replacement and consolidation pool to preventthe added overhead in consolidating the chaotic block during sequentialwrite and consolidation of potentially an open sequential or an openchaotic block to manage the subsequent FAT and Directory update.

A generalization of the present scheme is to classify the update blocksbased on a set of attributes, such as whether the update block isstoring sequential or non-sequential data or whether it is storing somepredefined type of system data. In implementing a pool of update blocksof limited number, each class of update blocks will have its own rulefor replacement when the maximum number supported for that class will beexceeded.

For example, sequential update block and non-sequential update blocksare two different classes. The replacement rules for each of theseclasses are the same, namely to replace a least active one with a newone. Thus, when the pool of sequential update blocks will be exceeded, aleast active one in the pool will be closed and removed before a new oneis introduced to the pool. Similarly for the pool of non-sequentialupdate blocks.

In general each class has its own replacement rule independent of theother classes. Examples of replacement rules are to replace the leastrecently accessed, the most recently accessed, the least frequentlyaccessed, the most frequently accessed, etc, depending on thecorresponding classes.

Additional features and advantages of the present invention will beunderstood from the following description of its preferred embodiments,which description should be taken in conjunction with the accompanyingdrawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates schematically the main hardware components of amemory system suitable for implementing the present invention.

FIG. 2 illustrates the memory being organized into physical groups ofsectors (or metablocks) and managed by a memory manager of thecontroller, according to a preferred embodiment of the invention.

FIGS. 3A(i)-3A(iii) illustrate schematically the mapping between alogical group and a metablock, according to a preferred embodiment ofthe present invention.

FIG. 3B illustrates schematically the mapping between logical groups andmetablocks.

FIG. 4 illustrates the alignment of a metablock with structures inphysical memory.

FIG. 5A illustrates metablocks being constituted from linking of minimumerase units of different planes.

FIG. 5B illustrates one embodiment in which one minimum erase unit (MEU)is selected from each plane for linking into a metablock.

FIG. 5C illustrates another embodiment in which more than one MEU areselected from each plane for linking into a metablock.

FIG. 6 is a schematic block diagram of the metablock management systemas implemented in the controller and flash memory.

FIG. 7A illustrates an example of sectors in a logical group beingwritten in sequential order to a sequential update block.

FIG. 7B illustrates an example of sectors in a logical group beingwritten in chaotic order to a chaotic update block.

FIG. 8 illustrates an example of sectors in a logical group beingwritten in sequential order to a sequential update block as a result oftwo separate host write operations that has a discontinuity in logicaladdresses.

FIG. 9 is a flow diagram illustrating a process by the update blockmanager to update a logical group of data, according a generalembodiment of the invention.

FIG. 10 is a flow diagram illustrating a process by the update blockmanager to update a logical group of data, according a preferredembodiment of the invention.

FIG. 11A is a flow diagram illustrating in more detail the consolidationprocess of closing a chaotic update block shown in FIG. 10.

FIG. 11B is a flow diagram illustrating in more detail the compactionprocess for closing a chaotic update block shown in FIG. 10.

FIG. 12A illustrates all possible states of a Logical Group, and thepossible transitions between them under various operations.

FIG. 12B is a table listing the possible states of a Logical Group.

FIG. 13A illustrates all possible states of a metablock, and thepossible transitions between them under various operations. A metablockis a Physical Group corresponding to a Logical Group.

FIG. 13B is a table listing the possible states of a metablock.

FIGS. 14(A)-14(J) are state diagrams showing the effect of variousoperations on the state of the logical group and also on the physicalmetablock.

FIG. 15 illustrates a preferred embodiment of the structure of anallocation block list (ABL) for keeping track of opened and closedupdate blocks and erased blocks for allocation.

FIG. 16A illustrates the data fields of a chaotic block index (CBI)sector.

FIG. 16B illustrates an example of the chaotic block index (CBI) sectorsbeing recorded in a dedicated metablock.

FIG. 16C is a flow diagram illustrating access to the data of a logicalsector of a given logical group undergoing chaotic update.

FIG. 16D is a flow diagram illustrating access to the data of a logicalsector of a given logical group undergoing chaotic update, according toan alternative embodiment in which logical group has been partitionedinto subgroups.

FIG. 16E illustrates examples of Chaotic Block Indexing (CBI) sectorsand their functions for the embodiment where each logical group ispartitioned into multiple subgroups.

FIG. 17A illustrates the data fields of a group address table (GAT)sector.

FIG. 17B illustrates an example of the group address table (GAT) sectorsbeing recorded in a GAT block.

FIG. 18 is a schematic block diagram illustrating the distribution andflow of the control and directory information for usage and recycling oferased blocks.

FIG. 19 is a flow chart showing the process of logical to physicaladdress translation.

FIG. 20 illustrates the hierarchy of the operations performed on controldata structures in the course of the operation of the memory management.

FIG. 21 illustrates schematically the two prescribed limits on thenumber of update blocks for a block managing system.

FIG. 22 illustrates typical examples of combinations of the two limitsoptimized for various memory devices.

FIG. 23A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22.

FIG. 23B illustrates schematically the closing of the least activeupdate block in order to make room for a new update block, according tothe previous scheme.

FIG. 23C illustrates schematically introducing a newly allocated updateblock into the pool after a closed update block has been removed to makeroom.

FIG. 24A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22.

FIG. 24B illustrates schematically the closing of the least activeupdate block in order to make room for a new update block, according tothe previous scheme.

FIG. 24C illustrates schematically introducing a newly allocated updateblock into the pool after a closed update block has been removed to makeroom.

FIG. 25A illustrates the scheme previously illustrated in FIG. 10, STEP410 and also in FIG. 23B and FIG. 24B where the least recently accessedupdate block is closed whenever a new allocation would exceed apredetermined limit.

FIG. 25B illustrates the scheme previously illustrated in FIG. 10, STEP370 where the least recently accessed chaotic (non-sequential) updateblock is closed whenever the number of chaotic update blocks exceeds apredetermined limit.

FIG. 26A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22.

FIG. 26B illustrates schematically the closing of one among the pool ofan update blocks in order to make room for a new update block, accordingto the present improved scheme.

FIG. 26C illustrates schematically introducing a newly allocated updateblock into the pool after a closed update block has been removed to makeroom.

FIG. 27A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22.

FIG. 27B illustrates schematically the closing of one among the pool ofan update blocks in order to make room for a new update block, accordingto the present improved scheme.

FIG. 27C illustrates schematically introducing a new chaotic updateblock into the pool after another chaotic update block has been closedand removed to make room.

FIG. 28 is a flow chart illustrating the present improved scheme ofmanaging a limited set of update blocks during a sequential update,according to a first embodiment.

FIG. 29 is a flow chart illustrating the present improved scheme ofmanaging a limited set of update blocks having two predetermined limits,according to a second embodiment.

FIG. 30 is a flow chart illustrating the present improved scheme ofmanaging a limited set of update blocks having class-based replacementrules.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

FIG. 1 to FIG. 20 illustrate examples of memory systems with blockmanagement in which the various aspects of the present invention may beimplemented. Similar memory systems have been disclosed in U.S. PatentApplication Publication No. US-2005-0144365-A1, entitled “Non-VolatileMemory and Method with Control Data Management,” by Gorobets et al.

FIG. 1 illustrates schematically the main hardware components of amemory system suitable for implementing the present invention. Thememory system 20 typically operates with a host 10 through a hostinterface. The memory system is typically in the form of a memory cardor an embedded memory system. The memory system 20 includes a memory 200whose operations are controlled by a controller 100. The memory 200comprises of one or more array of non-volatile memory cells distributedover one or more integrated circuit chip. The controller 100 includes aninterface 110, a processor 120, an optional coprocessor 121, ROM 122(read-only-memory), RAM 130 (random access memory) and optionallyprogrammable nonvolatile memory 124. The interface 110 has one componentinterfacing the controller to a host and another component interfacingto the memory 200. Firmware stored in nonvolatile ROM 122 and/or theoptional nonvolatile memory 124 provides codes for the processor 120 toimplement the functions of the controller 100. Error correction codesmay be processed by the processor 120 or the optional coprocessor 121.In an alternative embodiment, the controller 100 is implemented by astate machine (not shown.) In yet another embodiment, the controller 100is implemented within the host.

Logical and Physical Block Structures

FIG. 2 illustrates the memory being organized into physical groups ofsectors (or metablocks) and managed by a memory manager of thecontroller, according to a preferred embodiment of the invention. Thememory 200 is organized into metablocks, where each metablock is a groupof physical sectors S₀, . . . , S_(N-1) that are erasable together.

The host 10 accesses the memory 200 when running an application under afile system or operating system. Typically, the host system addressesdata in units of logical sectors where, for example, each sector maycontain 512 bytes of data. Also, it is usual for the host to read orwrite to the memory system in unit of logical clusters, each consistingof one or more logical sectors. In some host systems, an optionalhost-side memory manager may exist to perform lower level memorymanagement at the host. In most cases during read or write operations,the host 10 essentially issues a command to the memory system 20 to reador write a segment containing a string of logical sectors of data withcontiguous addresses.

A memory-side memory manager is implemented in the controller 100 of thememory system 20 to manage the storage and retrieval of the data of hostlogical sectors among metablocks of the flash memory 200. In thepreferred embodiment, the memory manager contains a number of softwaremodules for managing erase, read and write operations of the metablocks.The memory manager also maintains system control and directory dataassociated with its operations among the flash memory 200 and thecontroller RAM 130.

FIGS. 3A(i)-3A(iii) illustrate schematically the mapping between alogical group and a metablock, according to a preferred embodiment ofthe present invention. The metablock of the physical memory has Nphysical sectors for storing N logical sectors of data of a logicalgroup. FIG. 3A(i) shows the data from a logical group LG_(i), where thelogical sectors are in contiguous logical order 0, 1, . . . , N−1. FIG.3A(ii) shows the same data being stored in the metablock in the samelogical order. The metablock when stored in this manner is said to be“sequential.” In general, the metablock may have data stored in adifferent order, in which case the metablock is said to be“non-sequential” or “chaotic.”

There may be an offset between the lowest address of a logical group andthe lowest address of the metablock to which it is mapped. In this case,logical sector address wraps round as a loop from bottom back to top ofthe logical group within the metablock. For example, in FIG. 3A(iii),the metablock stores in its first location beginning with the data oflogical sector k. When the last logical sector N−1 is reached, it wrapsaround to sector 0 and finally storing data associated with logicalsector k−1 in its last physical sector. In the preferred embodiment, apage tag is used to identify any offset, such as identifying thestarting logical sector address of the data stored in the first physicalsector of the metablock. Two blocks will be considered to have theirlogical sectors stored in similar order when they only differ by a pagetag.

FIG. 3B illustrates schematically the mapping between logical groups andmetablocks. Each logical group is mapped to a unique metablock, exceptfor a small number of logical groups in which data is currently beingupdated. After a logical group has been updated, it may be mapped to adifferent metablock. The mapping information is maintained in a set oflogical to physical directories, which will be described in more detaillater.

Other types of logical group to metablock mapping are also comtemplated.For example, metablocks with variable size are disclosed in co-pendingand co-owned United States Patent application, entitled, “AdaptiveMetablocks,” filed by Alan Sinclair, on the same day as the presentapplication. The entire disclosure of the co-pending application ishereby incorporated herein by reference.

One feature of the invention is that the system operates with a singlelogical partition, and groups of logical sectors throughout the logicaladdress range of the memory system are treated identically. For example,sectors containing system data and sectors containing user data can bedistributed anywhere among the logical address space.

Unlike prior art systems, there is no special partitioning or zoning ofsystem sectors (i.e., sectors relating to file allocation tables,directories or sub-directories) in order to localize in logical addressspace sectors that are likely to contain data with high-frequency andsmall-size updates. Instead, the present scheme of updating logicalgroups of sectors will efficiently handle the patterns of access thatare typical of system sectors, as well as those typical of file data.

FIG. 4 illustrates the alignment of a metablock with structures inphysical memory. Flash memory comprises blocks of memory cells which areerasable together as a unit. Such erase blocks are the minimum unit oferasure of flash memory or minimum erasable unit (MEU) of the memory.The minimum erase unit is a hardware design parameter of the memory,although in some memory systems that supports multiple MEUs erase, it ispossible to configure a “super MEU” comprising more than one MEU. Forflash EEPROM, a MEU may comprise one sector but preferably multiplesectors. In the example shown, it has M sectors. In the preferredembodiment, each sector can store 512 bytes of data and has a user dataportion and a header portion for storing system or overhead data. If themetablock is constituted from P MEUs, and each MEU contains M sectors,then, each metablock will have N=P*M sectors.

The metablock represents, at the system level, a group of memorylocations, e.g., sectors that are erasable together. The physicaladdress space of the flash memory is treated as a set of metablocks,with a metablock being the minimum unit of erasure. Within thisspecification, the terms “metablock” and “block” are used synonymouslyto define the minimum unit of erasure at the system level for mediamanagement, and the term “minimum erase unit” or MEU is used to denotethe minimum unit of erasure of flash memory.

Linking of Minimum Erase Units (MEUs) to Form a Metablock

In order to maximize programming speed and erase speed, parallelism isexploited as much as possible by arranging for multiple pages ofinformation, located in multiple MEUs, to be programmed in parallel, andfor multiple MEUs to be erased in parallel.

In flash memory, a page is a grouping of memory cells that may beprogrammed together in a single operation. A page may comprise one ormore sector. Also, a memory array may be partitioned into more than oneplane, where only one MEU within a plane may be programmed or erased ata time. Finally, the planes may be distributed among one or more memorychips.

In flash memory, the MEUs may comprise one or more page. MEUs within aflash memory chip may be organized in planes. Since one MEU from eachplane may be programmed or erased concurrently, it is expedient to forma multiple MEU metablock by selecting one MEU from each plane (see FIG.5B below.)

FIG. 5A illustrates metablocks being constituted from linking of minimumerase units of different planes. Each metablock, such as MB0, MB1, . . ., is constituted from MEUs from different planes of the memory system,where the different planes may be distributed among one or more chips.The metablock link manager 170 shown in FIG. 2 manages the linking ofthe MEUs for each metablock. Each metablock is configured during aninitial formatting process, and retains its constituent MEUs throughoutthe life of the system, unless there is a failure of one of the MEUs.

FIG. 5B illustrates one embodiment in which one minimum erase unit (MEU)is selected from each plane for linking into a metablock.

FIG. 5C illustrates another embodiment in which more than one MEU areselected from each plane for linking into a metablock. In anotherembodiment, more than one MEU may be selected from each plane to form asuper MEU. For example, a super MEU may be formed from two MEUs. In thiscase, it may take more than one pass for read or write operation.

The linking and re-linking of MEUs into metablocks is also disclosed inco-pending and co-owned United States Patent application, entitled“Adaptive Deterministic Grouping of Blocks into Multi-Block Structures,”filed by Carlos Gonzales et al, on the same day as the presentapplication. The entire disclosure of the co-pending application ishereby incorporated herein by reference.

Metablock Management

FIG. 6 is a schematic block diagram of the metablock management systemas implemented in the controller and flash memory. The metablockmanagement system comprises various functional modules implemented inthe controller 100 and maintains various control data (includingdirectory data) in tables and lists hierarchically distributed in theflash memory 200 and the controller RAM 130. The function modulesimplemented in the controller 100 includes an interface module 110, alogical-to-physical address translation module 140, an update blockmanager module 150, an erase block manager module 160 and a metablocklink manager 170.

The interface 110 allows the metablock management system to interfacewith a host system. The logical to physical address translation module140 maps the logical address from the host to a physical memorylocation. The update block Manager module 150 manages data updateoperations in memory for a given logical group of data. The erased blockmanager 160 manages the erase operation of the metablocks and theirallocation for storage of new information. A metablock link manager 170manages the linking of subgroups of minimum erasable blocks of sectorsto constitute a given metablock. Detailed description of these moduleswill be given in their respective sections.

During operation the metablock management system generates and workswith control data such as addresses, control and status information.Since much of the control data tends to be frequently changing data ofsmall size, it can not be readily stored and maintained efficiently in aflash memory with a large block structure. A hierarchical anddistributed scheme is employed to store the more static control data inthe nonvolatile flash memory while locating the smaller amount of themore varying control data in controller RAM for more efficient updateand access. In the event of a power shutdown or failure, the schemeallows the control data in the volatile controller RAM to be rebuiltquickly by scanning a small set of control data in the nonvolatilememory. This is possible because the invention restricts the number ofblocks associated with the possible activity of a given logical group ofdata. In this way, the scanning is confined. In addition, some of thecontrol data that requires persistence are stored in a nonvolatilemetablock that can be updated sector-by-sector, with each updateresulting in a new sector being recorded that supercedes a previous one.A sector indexing scheme is employed for control data to keep track ofthe sector-by-sector updates in a metablock.

The non-volatile flash memory 200 stores the bulk of control data thatare relatively static. This includes group address tables (GAT) 210,chaotic block indices (CBI) 220, erased block lists (EBL) 230 and MAP240. The GAT 210 keeps track of the mapping between logical groups ofsectors and their corresponding metablocks. The mappings do not changeexcept for those undergoing updates. The CBI 220 keeps track of themapping of logically non-sequential sectors during an update. The EBL230 keeps track of the pool of metablocks that have been erased. MAP 240is a bitmap showing the erase status of all metablocks in the flashmemory.

The volatile controller RAM 130 stores a small portion of control datathat are frequently changing and accessed. This includes an allocationblock list (ABL) 134 and a cleared block list (CBL) 136. The ABL 134keeps track of the allocation of metablocks for recording update datawhile the CBL 136 keeps track of metablocks that have been deallocatedand erased. In the preferred embodiment, the RAM 130 acts as a cache forcontrol data stored in flash memory 200.

Update Block Manager

The update block manager 150 (shown in FIG. 2) handles the update oflogical groups. According to one aspect of the invention, each logicalgroup of sectors undergoing an update is allocated a dedicated updatemetablock for recording the update data. In the preferred embodiment,any segment of one or more sectors of the logical group will be recordedin the update block. An update block can be managed to receive updateddata in either sequential order or non-sequential (also known aschaotic) order. A chaotic update block allows sector data to be updatedin any order within a logical group, and with any repetition ofindividual sectors. In particular, a sequential update block can becomea chaotic update block, without need for relocation of any data sectors.No predetermined allocation of blocks for chaotic data update isrequired; a non-sequential write at any logical address is automaticallyaccommodated. Thus, unlike prior art systems, there is no specialtreatment whether the various update segments of the logical group is inlogical sequential or non-sequential order. The generic update blockwill simply be used to record the various segments in the order they arerequested by the host. For example, even if host system data or systemcontrol data tends to be updated in chaotic fashion, regions of logicaladdress space corresponding to host system data do not need to betreated differently from regions with host user data.

Data of a complete logical group of sectors is preferably stored inlogically sequential order in a single metablock. In this way, the indexto the stored logical sectors is predefined. When the metablock has instore all the sectors of a given logical group in a predefined order itis said to be “intact.” As for an update block, when it eventually fillsup with update data in logically sequential order, then the update blockwill become an updated intact metablock that readily replace theoriginal metablock. On the other hand, if the update block fills up withupdate data in a logically different order from that of the intactblock, the update block is a non-sequential or chaotic update block andthe out of order segments must be further processed so that eventuallythe update data of the logical group is stored in the same order as thatof the intact block. In the preferred case, it is in logicallysequential order in a single metablock. The further processing involvesconsolidating the updated sectors in the update block with unchangedsectors in the original block into yet another update metablock. Theconsolidated update block will then be in logically sequential order andcan be used to replace the original block. Under some predeterminedcondition, the consolidation process is preceded by one or morecompaction processes. The compaction process simply re-records thesectors of the chaotic update block into a replacing chaotic updateblock while eliminating any duplicate logical sector that has beenrendered obsolete by a subsequent update of the same logical sector.

The update scheme allows for multiple update threads runningconcurrently, up to a predefined maximum. Each thread is a logical groupundergoing updates using its dedicated update metablock.

Sequential Data Update

When data belonging to a logical group is first updated, a metablock isallocated and dedicated as an update block for the update data of thelogical group. The update block is allocated when a command is receivedfrom the host to write a segment of one or more sectors of the logicalgroup for which an existing metablock has been storing all its sectorsintact. For the first host write operation, a first segment of data isrecorded on the update block. Since each host write is a segment of oneor more sector with contiguous logical address, it follows that thefirst update is always sequential in nature. In subsequent host writes,update segments within the same logical group are recorded in the updateblock in the order received from the host. A block continues to bemanaged as a sequential update block whilst sectors updated by the hostwithin the associated logical group remain logically sequential. Allsectors updated in this logical group are written to this sequentialupdate block, until the block is either closed or converted to a chaoticupdate block.

FIG. 7A illustrates an example of sectors in a logical group beingwritten in sequential order to a sequential update block as a result oftwo separate host write operations, whilst the corresponding sectors inthe original block for the logical group become obsolete. In host writeoperation #1, the data in the logical sectors LS5-LS8 are being updated.The updated data as LS5′-LS8′ are recorded in a newly allocateddedicated update block.

For expediency, the first sector to be updated in the logical group isrecorded in the dedicated update block starting from the first physicalsector location. In general, the first logical sector to be updated isnot necessarily the logical first sector of the group, and there maytherefore be an offset between the start of the logical group and thestart of the update block. This offset is known as page tag as describedpreviously in connection with FIG. 3A. Subsequent sectors are updated inlogically sequential order. When the last sector of the logical group iswritten, group addresses wrap around and the write sequence continueswith the first sector of the group.

In host write operation #2, the segment of data in the logical sectorsLS9-LS12 are being updated. The updated data as LS9′-LS12′ are recordedin the dedicated update block in a location directly following where thelast write ends. It can be seen that the two host writes are such thatthe update data has been recorded in the update block in logicallysequential order, namely LS5′-LS12′. The update block is regarded as asequential update block since it has been filled in logically sequentialorder. The update data recorded in the update block obsoletes thecorresponding ones in the original block.

Chaotic Data Update

Chaotic update block management may be initiated for an existingsequential update block when any sector updated by the host within theassociated logical group is logically non-sequential. A chaotic updateblock is a form of data update block in which logical sectors within anassociated logical group may be updated in any order and with any amountof repetition. It is created by conversion from a sequential updateblock when a sector written by a host is logically non-sequential to thepreviously written sector within the logical group being updated. Allsectors subsequently updated in this logical group are written in thenext available sector location in the chaotic update block, whatevertheir logical sector address within the group.

FIG. 7B illustrates an example of sectors in a logical group beingwritten in chaotic order to a chaotic update block as a result of fiveseparate host write operations, whilst superseded sectors in theoriginal block for the logical group and duplicated sectors in thechaotic update block become obsolete. In host write operation #1, thelogical sectors LS10-LS11 of a given logical group stored in an originalmetablock is updated. The updated logical sectors LS10′-LS11′ are storedin a newly allocated update block. At this point, the update block is asequential one. In host write operation #2, the logical sectors LS5-LS6are updated as LS5′-LS6′ and recorded in the update block in thelocation immediately following the last write. This converts the updateblock from a sequential to a chaotic one. In host write operation #3,the logical sector LS10 is being updated again and is recorded in thenext location of the update block as LS10″. At this point LS10″ in theupdate block supersedes LS10′ in a previous recording which in turnssupercedes LS10 in the original block. In host write operation #4, thedata in the logical sector LS10 is again updated and is recorded in thenext location of the update block as LS10′″. Thus, LS10′″ is now thelatest and only valid data for the logical sector LS10. In host writeoperation #5, the data in logical sector LS30 is being updated andrecorded in the update block as LS30′. Thus, the example illustratesthat sectors within a logical group can be written in a chaotic updateblock in any order and with any repetition.

Forced Sequential Update

FIG. 8 illustrates an example of sectors in a logical group beingwritten in sequential order to a sequential update block as a result oftwo separate host write operations that has a discontinuity in logicaladdresses. In host write #1, the update data in the logical sectorsLS5-LS8 is recorded in a dedicated update block as LS5′-LS8′. In hostwrite #2, the update data in the logical sectors LS14-LS16 is beingrecorded in the update block following the last write as LS14′-LS16′.However, there is an address jump between LS8 and LS14 and the hostwrite #2 would normally render the update block non-sequential. Sincethe address jump is not substantial, one option is to first perform apadding operation (#2A) by copying the data of the intervening sectorsfrom the original block to the update block before executing host write#2. In this way, the sequential nature of the update block is preserved.

FIG. 9 is a flow diagram illustrating a process by the update blockmanager to update a logical group of data, according a generalembodiment of the invention. The update process comprises the followingsteps:

STEP 260: The memory is organized into blocks, each block partitionedinto memory units that are erasable together, each memory unit forstoring a logical unit of data.

STEP 262: The data is organized into logical groups, each logical grouppartitioned into logical units.

STEP 264: In the standard case, all logical units of a logical group isstored among the memory units of an original block according to a firstprescribed order, preferably, in logically sequential order. In thisway, the index for accessing the individual logical units in the blockis known.

STEP 270: For a given logical group (e.g., LG_(X)) of data, a request ismade to update a logical unit within LG_(X). (A logical unit update isgiven as an example. In general the update will be a segment of one ormore contiguous logical units within LG_(X).)

STEP 272: The requested update logical unit is to be stored in a secondblock, dedicated to recording the updates of LG_(X). The recording orderis according to a second order, typically, the order the updates arerequested. One feature of the invention allows an update block to be setup initially generic to recording data in logically sequential orchaotic order. So depending on the second order, the second block can bea sequential one or a chaotic one.

STEP 274: The second block continues to have requested logical unitsrecorded as the process loops back to STEP 270. The second block will beclosed to receiving further update when a predetermined condition forclosure materializes. In that case, the process proceeds to STEP 276.

STEP 276: Determination is made whether or not the closed, second blockhas its update logical units recorded in a similar order as that of theoriginal block. The two blocks are considered to have similar order whenthey recorded logical units differ by only a page tag, as described inconnection with FIG. 3A. If the two blocks have similar order theprocess proceeds to STEP 280, otherwise, some sort of garbage collectionneed to be performed in STEP 290.

STEP 280: Since the second block has the same order as the first block,it is used to replace the original, first block. The update process thenends at STEP 299.

STEP 290: The latest version of each logical units of the given logicalgroup are gathered from among the second block (update block) and thefirst block (original block). The consolidated logical units of thegiven logical group are then written to a third block in an ordersimilar to the first block.

STEP 292: Since the third block (consolidated block) has a similar orderto the first block, it is used to replace the original, first block. Theupdate process then ends at STEP 299.

STEP 299: When a closeout process creates an intact update block, itbecomes the new standard block for the given logical group. The updatethread for the logical group will be terminated.

FIG. 10 is a flow diagram illustrating a process by the update blockmanager to update a logical group of data, according a preferredembodiment of the invention. The update process comprises the followingsteps:

STEP 310: For a given logical group (e.g., LG_(X)) of data, a request ismade to update a logical sector within LG_(X). (A sector update is givenas an example. In general the update will be a segment of one or morecontiguous logical sectors within LG_(x).)

STEP 312: If an update block dedicated to LG_(X) does not already exist,proceed to STEP 410 to initiate a new update thread for the logicalgroup. This will be accomplished by allocating an update block dedicatedto recording update data of the logical group. If there is already anupdate block open, proceed to STEP 314 to begin recording the updatesector onto the update block.

STEP 314: If the current update block is already chaotic (i.e.,non-sequential) then simply proceed to STEP 510 for recording therequested update sector onto the chaotic update block. If the currentupdate block is sequential, proceed to STEP 316 for processing of asequential update block.

STEP 316: One feature of the invention allows an update block to be setup initially generic to recording data in logically sequential orchaotic order. However, since the logical group ultimately has its datastored in a metablock in a logically sequential order, it is desirableto keep the update block sequential as far as possible. Less processingwill then be required when an update block is closed to further updatesas garbage collection will not be needed.

Thus determination is made whether the requested update will follow thecurrent sequential order of the update block. If the update followssequentially, then proceed to STEP 510 to perform a sequential update,and the update block will remain sequential. On the other hand, if theupdate does not follow sequentially (chaotic update), it will convertthe sequential update block to a chaotic one if no other actions aretaken.

In one embodiment, nothing more is done to salvage the situation and theprocess proceeds directly to STEP 370 where the update is allowed toturn the update block into a chaotic one.

Optional Forced Sequential Process

In another embodiment, a forced sequential process STEP 320 isoptionally performed to preserve the sequential update block as far aspossible in view of a pending chaotic update. There are two situations,both of which require copying missing sectors from the original block tomaintain the sequential order of logical sectors recorded on the updateblock. The first situation is where the update creates a short addressjump. The second situation is to prematurely close out an update blockin order to keep it sequential. The forced sequential process STEP 320comprises the following substeps:

STEP 330: If the update creates a logical address jump not greater apredetermined amount, C_(B), the process proceeds to a forced sequentialupdate process in STEP 350, otherwise the process proceeds to STEP 340to consider if it qualifies for a forced sequential closeout.

STEP 340: If the number of unfilled physical sectors exceeds apredetermined design parameter, C_(C), whose typical value is half ofthe size of the update block, then the update block is relatively unusedand will not be prematurely closed. The process proceeds to STEP 370 andthe update block will become chaotic. On the other hand, if the updateblock is substantially filled, it is considered to have been wellutilized already and therefore is directed to STEP 360 for forcedsequential closeout.

STEP 350: Forced sequential update allows current sequential updateblock to remain sequential as long as the address jump does not exceed apredetermined amount, C_(B). Essentially, sectors from the updateblock's associated original block are copied to fill the gap spanned bythe address jump. Thus, the sequential update block will be padded withdata in the intervening addresses before proceeding to STEP 510 torecord the current update sequentially.

STEP 360: Forced sequential closeout allows the currently sequentialupdate block to be closed out if it is already substantially filledrather than converted to a chaotic one by the pending chaotic update. Achaotic or non-sequential update is defined as one with a forwardaddress transition not covered by the address jump exception describedabove, a backward address transition, or an address repetition. Toprevent a sequential update block to be converted by a chaotic update,the unwritten sector locations of the update block are filled by copyingsectors from the update block's associated original partly-obsoleteblock. The original block is then fully obsolete and may be erased. Thecurrent update block now has the full set of logical sectors and is thenclosed out as an intact metablock replacing the original metablock. Theprocess then proceeds to STEP 430 to have a new update block allocatedin its place to accept the recording of the pending sector update thatwas first requested in STEP 310.

Conversion to Chaotic Update Block

STEP 370: When the pending update is not in sequential order andoptionally, if the forced sequential conditions are not satisfied, thesequential update block is allowed to be converted to a chaotic one byvirtue of allowing the pending update sector, with non-sequentialaddress, to be recorded on the update block when the process proceeds toSTEP 510. If the maximum number of chaotic update blocks exist, it isnecessary to close the least recently accessed chaotic update blockbefore allowing the conversion to proceed; thus preventing the maximumnumber of chaotic blocks from being exceeded. The identification of theleast recently accessed chaotic update block is the same as the generalcase described in STEP 420, but is constrained to chaotic update blocksonly. Closing a chaotic update block at this time is achieved byconsolidation as described in STEP 550.

Allocation of New Update Block Subject to System Restriction

STEP 410: The process of allocating an erase metablock as an updateblock begins with the determination whether a predetermined systemlimitation is exceeded or not. Due to finite resources, the memorymanagement system typically allows a predetermined maximum number ofupdate blocks, U_(MAX), to exist concurrently. This limit is theaggregate of sequential update blocks and chaotic update blocks, and isa design parameter. In a preferred embodiment, the limit is, forexample, a maximum of 8 update blocks. Also, due to the higher demand onsystem resources, there may also be a corresponding predetermined limiton the maximum number of chaotic update blocks that can be openconcurrently (e.g., 4.)

Thus, when U_(MAX) update blocks have already been allocated, then thenext allocation request could only be satisfied after closing one of theexisting allocated ones. The process proceeds to STEP 420. When thenumber of open update blocks is less than C_(A), the process proceedsdirectly to STEP 430.

STEP 420: In the event the maximum number of update blocks, C_(A), isexceeded, the least-recently accessed update block is closed and garbagecollection is performed. The least recently accessed update block isidentified as the update block associated with the logical block thathas been accessed least recently. For the purpose of determining theleast recently accessed blocks, an access includes writes and optionallyreads of logical sectors. A list of open update blocks is maintained inorder of access; at initialization, no access order is assumed. Theclosure of an update block follows along the similar process describedin connection with STEP 360 and STEP 530 when the update block issequential, and in connection with STEP 540 when the update block ischaotic. The closure makes room for the allocation of a new update blockin STEP 430.

STEP 430: The allocation request is fulfilled with the allocation of anew metablock as an update block dedicated to the given logical groupLG_(X). The process then proceeds to STEP 510.

Record Update Data onto Update Block

STEP 510: The requested update sector is recorded onto next availablephysical location of the update block. The process then proceeds to STEP520 to determine if the update block is ripe for closeout.

Update Block Closeout

STEP 520: If the update block still has room for accepting additionalupdates, proceed to STEP 570. Otherwise proceed to STEP 522 to closeoutthe update block. There are two possible implementations of filling upan update block when the current requested write attempts to write morelogical sectors than the block has room for. In the firstimplementation, the write request is split into two portions, with thefirst portion writing up to the last physical sector of the block. Theblock is then closed and the second portion of the write will be treatedas the next requested write. In the other implementation, the requestedwrite is withheld while the block has it remaining sectors padded and isthen closed. The requested write will be treated as the next requestedwrite.

STEP 522: If the update block is sequential, proceed to STEP 530 forsequential closure. If the update block is chaotic, proceed to STEP 540for chaotic closure.

Sequential Update Block Closeout

STEP 530: Since the update block is sequential and fully filled, thelogical group stored in it is intact. The metablock is intact andreplaces the original one. At this time, the original block is fullyobsolete and may be erased. The process then proceeds to STEP 570 wherethe update thread for the given logical group ends.

Chaotic Update Block Closeout

STEP 540: Since the update block is non-sequentially filled and maycontain multiple updates of some logical sectors, garbage collection isperformed to salvage the valid data in it. The chaotic update block willeither be compacted or consolidated. Which process to perform will bedetermined in STEP 542.

STEP 542: To perform compaction or consolidation will depend on thedegeneracy of the update block. If a logical sector is updated multipletimes, its logical address is highly degenerate. There will be multipleversions of the same logical sector recorded on the update block andonly the last recorded version is the valid one for that logical sector.In an update block containing logical sectors with multiple versions,the number of distinct logical sectors will be much less than that of alogical group.

In the preferred embodiment, when the number of distinct logical sectorsin the update block exceeds a predetermined design parameter, C_(D),whose typical value is half of the size of a logical group, the closeoutprocess will perform a consolidation in STEP 550, otherwise the processwill proceed to compaction in STEP 560.

STEP 550: If the chaotic update block is to be consolidated, theoriginal block and the update block will be replaced by a new standardmetablock containing the consolidated data. After consolidation theupdate thread will end in STEP 570.

STEP 560: If the chaotic update block is to be compacted, it will bereplaced by a new update block carrying the compacted data. Aftercompaction the processing of the compacted update block will end in STEP570. Alternatively, compaction can be delayed until the update block iswritten to again, thus removing the possibility of compaction beingfollowed by consolidation without intervening updates. The new updateblock will then be used in further updating of the given logical blockwhen a next request for update in LG_(X) appears in STEP 502.

STEP 570: When a closeout process creates an intact update block, itbecomes the new standard block for the given logical group. The updatethread for the logical group will be terminated. When a closeout processcreates a new update block replacing an existing one, the new updateblock will be used to record the next update requested for the givenlogical group. When an update block is not closed out, the processingwill continue when a next request for update in LG_(X) appears in STEP310.

As can be seen from the process described above, when a chaotic updateblock is closed, the update data recorded on it is further processed. Inparticular its valid data is garbage collected either by a process ofcompaction to another chaotic block, or by a process of consolidationwith its associated original block to form a new standard sequentialblock.

FIG. 11A is a flow diagram illustrating in more detail the consolidationprocess of closing a chaotic update block shown in FIG. 10. Chaoticupdate block consolidation is one of two possible processes performedwhen the update block is being closed out, e.g., when the update blockis full with its last physical sector location written. Consolidation ischosen when the number of distinct logical sectors written in the blockexceeds a predetermined design parameter, C_(D). The consolidationprocess STEP 550 shown in FIG. 10 comprises the following substeps:

STEP 551: When a chaotic update block is being closed, a new metablockreplacing it will be allocated.

STEP 552: Gather the latest version of each logical sector among thechaotic update block and its associated original block, ignoring all theobsolete sectors.

STEP 554: Record the gathered valid sectors onto the new metablock inlogically sequential order to form an intact block, i.e., a block withall the logical sectors of a logical group recorded in sequential order.

STEP 556: Replace the original block with the new intact block.

STEP 558: Erase the closed out update block and the original block.

FIG. 11B is a flow diagram illustrating in more detail the compactionprocess for closing a chaotic update block shown in FIG. 10. Compactionis chosen when the number of distinct logical sectors written in theblock is below a predetermined design parameter, C_(D). The compactionprocess STEP 560 shown in FIG. 10 comprises the following substeps:

STEP 561: When a chaotic update block is being compacted, a newmetablock replacing it will be allocated.

STEP 562: Gather the latest version of each logical sector among theexisting chaotic update block to be compacted.

STEP 564: Record the gathered sectors onto the new update block to forma new update block having compacted sectors.

STEP 566: Replace the existing update block with the new update blockhaving compacted sectors.

STEP 568: Erase the closed out update block

Logical and Metablock States

FIG. 12A illustrates all possible states of a Logical Group, and thepossible transitions between them under various operations.

FIG. 12B is a table listing the possible states of a Logical Group. TheLogical Group states are defined as follows:

1. Intact: All logical sectors in the Logical Group have been written inlogically sequential order, possibly using page tag wrap around, in asingle metablock.

2. Unwritten: No logical sector in the Logical Group has ever beenwritten. The Logical Group is marked as unwritten in a group addresstable and has no allocated metablock. A predefined data pattern isreturned in response to a host read for every sector within this group.

3. Sequential Update: Some sectors within the Logical Group have beenwritten in logically sequential order in a metablock, possibly usingpage tag, so that they supersede the corresponding logical sectors fromany previous Intact state of the group.

4. Chaotic Update: Some sectors within the Logical Group have beenwritten in logically non-sequential order in a metablock, possibly usingpage tag, so that they supersede the corresponding logical sectors fromany previous Intact state of the group. A sector within the group may bewritten more than once, with the latest version superseding all previousversions.

FIG. 13A illustrates all possible states of a metablock, and thepossible transitions between them under various operations.

FIG. 13B is a table listing the possible states of a metablock. Themetablock states are defined as follows:

1. Erased: All the sectors in the metablock are erased.

2. Sequential Update: The metablock is partially written with sectors inlogically sequential order, possibly using page tag. All the sectorsbelong to the same Logical Group.3. Chaotic Update: The metablock is partially or fully written withsectors in logically non-sequential order. Any sector can be writtenmore than once. All sectors belong to the same Logical Group.

4: Intact: The metablock is fully written in logically sequential order,possibly using page tag. 5: Original: The metablock was previouslyIntact but at least one sector has been made obsolete by a host dataupdate.

FIGS. 14(A)-14(J) are state diagrams showing the effect of variousoperations on the state of the logical group and also on the physicalmetablock.

FIG. 14(A) shows state diagrams corresponding to the logical group andthe metablock transitions for a first write operation. The host writesone or more sectors of a previously unwritten Logical Group in logicallysequential order to a newly allocated Erased metablock. The LogicalGroup and the metablock go to the Sequential Update state.

FIG. 14(B) shows state diagrams corresponding to the logical group andthe metablock transitions for a first intact operation. A previouslyunwritten Sequential Update Logical Group becomes Intact as all thesectors are written sequentially by the host. The transition can alsohappen if the card fills up the group by filling the remaining unwrittensectors with a predefined data pattern. The metablock becomes Intact.

FIG. 14(C) shows state diagrams corresponding to the logical group andthe metablock transitions for a first chaotic operation. A previouslyunwritten Sequential Update Logical Group becomes Chaotic when at leastone sector has been written non-sequentially by the host.

FIG. 14(D) shows state diagrams corresponding to the logical group andthe metablock transitions for a first compaction operation. All validsectors within a previously unwritten Chaotic Update Logical Group arecopied to a new Chaotic metablock from the old block, which is thenerased.

FIG. 14(E) shows state diagrams corresponding to the logical group andthe metablock transitions for a first consolidation operation. All validsectors within a previously unwritten Chaotic Update Logical Group aremoved from the old Chaotic block to fill a newly allocated Erased blockin logically sequential order. Sectors unwritten by the host are filledwith a predefined data pattern. The old chaotic block is then erased.

FIG. 14(F) shows state diagrams corresponding to the logical group andthe metablock transitions for a sequential write operation. The hostwrites one or more sectors of an Intact Logical Group in logicallysequential order to a newly allocated Erased metablock. The LogicalGroup and the metablock go to Sequential Update state. The previouslyIntact metablock becomes an Original metablock.

FIG. 14(G) shows state diagrams corresponding to the logical group andthe metablock transitions for a sequential fill operation. A SequentialUpdate Logical Group becomes Intact when all its sectors are writtensequentially by the host. This may also occur during garbage collectionwhen the Sequential Update Logical Group is filled with valid sectorsfrom the original block in order to make it Intact, after which theoriginal block is erased.

FIG. 14(H) shows state diagrams corresponding to the logical group andthe metablock transitions for a non-sequential write operation. ASequential Update Logical Group becomes Chaotic when at least one sectoris written non-sequentially by the host. The non-sequential sectorwrites may cause valid sectors in either the Update block or thecorresponding Original block to become obsolete.

FIG. 14(I) shows state diagrams corresponding to the logical group andthe metablock transitions for a compaction operation. All valid sectorswithin a Chaotic Update Logical Group are copied into a new chaoticmetablock from the old block, which is then erased. The Original blockis unaffected.

FIG. 14(J) shows state diagrams corresponding to the logical group andthe metablock transitions for a consolidation operation. All validsectors within a Chaotic Update Logical Group are copied from the oldchaotic block and the Original block to fill a newly allocated Erasedblock in logically sequential order. The old chaotic block and theOriginal block are then erased.

Update Block Tracking and Management

FIG. 15 illustrates a preferred embodiment of the structure of anallocation block list (ABL) for keeping track of opened and closedupdate blocks and erased blocks for allocation. The allocation blocklist (ABL) 610 is held in controller RAM 130, to allow management ofallocation of erased blocks, allocated update blocks, associated blocksand control structures, and to enable correct logical to physicaladdress translation. In the preferred embodiment, the ABL includes alist of erased blocks, an open update block list 614 and a closed updateblock list 616.

The open update block list 614 is the set of block entries in the ABLwith the attributes of Open Update Block. The open update block list hasone entry for each data update block currently open. Each entry holdsthe following information. LG is the logical group address the currentupdate metablock is dedicated to. Sequential/Chaotic is a statusindicating whether the update block has been filled with sequential orchaotic update data. MB is the metablock address of the update block.Page tag is the starting logical sector recorded at the first physicallocation of the update block. Number of sectors written indicates thenumber of sectors currently written onto the update block. MB₀ is themetablock address of the associated original block. Page Tag₀ is thepage tag of the associated original block.

The closed update block list 616 is a subset of the Allocation BlockList (ABL). It is the set of block entries in the ABL with theattributes of Closed Update Block. The closed update block list has oneentry for each data update block which has been closed, but whose entryhas not been updated in a logical to a main physical directory. Eachentry holds the following information. LG is the logical group addressthe current update block is dedicated to. MB is the metablock address ofthe update block. Page tag is the starting logical sector recorded atthe first physical location of the update block. MB₀ is the metablockaddress of the associated original block.

Chaotic Block Indexing

A sequential update block has the data stored in logically sequentialorder, thus any logical sector among the block can be located easily. Achaotic update block has its logical sectors stored out of order and mayalso store multiple update generations of a logical sector. Additionalinformation must be maintained to keep track of where each valid logicalsector is located in the chaotic update block.

In the preferred embodiment, chaotic block indexing data structuresallow tracking and fast access of all valid sectors in a chaotic block.Chaotic block indexing independently manages small regions of logicaladdress space, and efficiently handles system data and hot regions ofuser data. The indexing data structures essentially allow indexinginformation to be maintained in flash memory with infrequent updaterequirement so that performance is not significantly impacted. On theother hand, lists of recently written sectors in chaotic blocks are heldin a chaotic sector list in controller RAM. Also, a cache of indexinformation from flash memory is held in controller RAM in order tominimize the number of flash sector accesses for address translation.Indexes for each chaotic block are stored in chaotic block index (CBI)sectors in flash memory.

FIG. 16A illustrates the data fields of a chaotic block index (CBI)sector. A Chaotic Block Index Sector (CBI sector) contains an index foreach sector in a logical group mapped to a chaotic update block,defining the location of each sector of the logical group within thechaotic update block or its associated original block. A CBI sectorincludes a chaotic block index field for keeping track of valid sectorswithin the chaotic block, a chaotic block info field for keeping trackof address parameters for the chaotic block, and a sector index fieldfor keeping track of the valid CBI sectors within the metablock (CBIblock) storing the CBI sectors.

FIG. 16B illustrates an example of the chaotic block index (CBI) sectorsbeing recorded in a dedicated metablock. The dedicated metablock will bereferred to as a CBI block 620. When a CBI sector is updated, it iswritten in the next available physical sector location in the CBI block620. Multiple copies of a CBI sector may therefore exist in the CBIblock, with only the last written copy being valid. For example the CBIsector for the logical group LG₁ has been updated three times with thelatest version being the valid one. The location of each valid sector inthe CBI block is identified by a set of indices in the last written CBIsector in the block. In this example, the last written CBI sector in theblock is CBI sector for LG₁₃₆ and its set of indices is the valid onesuperceding all previous ones. When the CBI block eventually becomesfully filled with CBI sectors, the block is compacted during a controlwrite operation by rewriting all valid sectors to a new block location.The full block is then erased.

The chaotic block index field within a CBI sector contains an indexentry for each logical sector within a logical group or sub-group mappedto a chaotic update block. Each index entry signifies an offset withinthe chaotic update block at which valid data for the correspondinglogical sector is located. A reserved index value indicates that novalid data for the logical sector exists in the chaotic update block,and that the corresponding sector in the associated original block isvalid. A cache of some chaotic block index field entries is held incontroller RAM.

The chaotic block info field within a CBI sector contains one entry foreach chaotic update block that exists in the system, recording addressparameter information for the block. Information in this field is onlyvalid in the last written sector in the CBI block. This information isalso present in data structures in RAM.

The entry for each chaotic update block includes three addressparameters. The first is the logical address of the logical group (orlogical group number) associated with the chaotic update block. Thesecond is the metablock address of the chaotic update block. The thirdis the physical address offset of the last sector written in the chaoticupdate block. The offset information sets the start point for scanningof the chaotic update block during initialization, to rebuild datastructures in RAM.

The sector index field contains an entry for each valid CBI sector inthe CBI block. It defines the offsets within the CBI block at which themost recently written CBI sectors relating to each permitted chaoticupdate block are located. A reserved value of an offset in the indexindicates that a permitted chaotic update block does not exist.

FIG. 16C is a flow diagram illustrating access to the data of a logicalsector of a given logical group undergoing chaotic update. During theupdate process, the update data is recorded in the chaotic update blockwhile the unchanged data remains in the original metablock associatedwith the logical group. The process of accessing a logical sector of thelogical group under chaotic update is as follows:

STEP 650: Begin locating a given logical sector of a given logicalgroup.

STEP 652: Locate last written CBI sector in the CBI block

STEP 654: Locate the chaotic update block or original block associatedwith the given logical group by looking up the Chaotic Block Info fieldof the last written CBI sector. This step can be performed any time justbefore STEP 662.

STEP 658: If the last written CBI sector is directed to the givenlogical group, the CBI sector is located. Proceed to STEP 662.Otherwise, proceed to STEP 660.

STEP 660: Locate the CBI sector for the given logical group by lookingup the sector index field of the last written CBI sector.

STEP 662: Locate the given logical sector among either the chaotic blockor the original block by looking up the Chaotic Block Index field of thelocated CBI sector.

FIG. 16D is a flow diagram illustrating access to the data of a logicalsector of a given logical group undergoing chaotic update, according toan alternative embodiment in which logical group has been partitionedinto subgroups. The finite capacity of a CBI sector can only keep trackof a predetermined maximum number of logical sectors. When the logicalgroup has more logical sectors than a single CBI sector can handle, thelogical group is partitioned into multiple subgroups with a CBI sectorassigned to each subgroup. In one example, each CBI sector has enoughcapacity for tracking a logical group consisting of 256 sectors and upto 8 chaotic update blocks. If the logical group has a size exceeding256 sectors, a separate CBI sector exists for each 256-sector sub-groupwithin the logical group. CBI sectors may exist for up to 8 sub-groupswithin a logical group, giving support for logical groups up to 2048sectors in size.

In the preferred embodiment, an indirect indexing scheme is employed tofacilitate management of the index. Each entry of the sector index hasdirect and indirect fields.

The direct sector index defines the offsets within the CBI block atwhich all possible CBI sectors relating to a specific chaotic updateblock are located. Information in this field is only valid in the lastwritten CBI sector relating to that specific chaotic update block. Areserved value of an offset in the index indicates that the CBI sectordoes not exist because the corresponding logical subgroup relating tothe chaotic update block either does not exist, or has not been updatedsince the update block was allocated.

The indirect sector index defines the offsets within the CBI block atwhich the most recently written CBI sectors relating to each permittedchaotic update block are located. A reserved value of an offset in theindex indicates that a permitted chaotic update block does not exist.

FIG. 16D shows the process of accessing a logical sector of the logicalgroup under chaotic update as follows:

STEP 670: Partition each Logical Group into multiple subgroups andassign a CBI sector to each subgroup

STEP 680: Begin locating a given logical sector of a given subgroup of agiven logical group.

STEP 682: Locate the last written CBI sector in the CBI block.

STEP 684: Locate the chaotic update block or original block associatedwith the given subgroup by looking up the Chaotic Block Info field ofthe last written CBI sector. This step can be performed any time justbefore STEP 696.

STEP 686: If the last written CBI sector is directed to the givenlogical group, proceed to STEP 691. Otherwise, proceed to STEP 690.

STEP 690: Locate the last written of the multiple CBI sectors for thegiven logical group by looking up the Indirect Sector Index field of thelast written CBI sector.

STEP 691: At least a CBI sector associate with one of the subgroups forthe given logical group has been located. Continue.

STEP 692: If the located CBI sector directed to the given subgroup, theCBI sector for the given subgroup is located. Proceed to STEP 696.Otherwise, proceed to STEP 694.

STEP 694: Locate the CBI sector for the given subgroup by looking up thedirect sector index field of the currently located CBI sector.

STEP 696: Locate the given logical sector among either the chaotic blockor the original block by looking up the Chaotic Block Index field of theCBI sector for the given subgroup.

FIG. 16E illustrates examples of Chaotic Block Indexing (CBI) sectorsand their functions for the embodiment where each logical group ispartitioned into multiple subgroups. A logical group 700 originally hasits intact data stored in an original metablock 702. The logical groupis then undergoing updates with the allocation of a dedicated chaoticupdate block 704. In the present examples, the logical group 700 ispartitioned into subgroups, such subgroups A, B, C, D, each having 256sectors.

In order to locate the ith sector in the subgroup B, the last writtenCBI sector in the CBI block 620 is first located. The chaotic block infofield of the last written CBI sector provides the address to locate thechaotic update block 704 for the given logical group. At the same timeit provides the location of the last sector written in the chaoticblock. This information is useful in the event of scanning andrebuilding indices.

If the last written CBI sector turns out to be one of the four CBIsectors of the given logical group, it will be further determined if itis exactly the CBI sector for the given subgroup B that contains the ithlogical sector. If it is, then the CBI sector's chaotic block index willpoint to the metablock location for storing the data for the ith logicalsector. The sector location could be either in the chaotic update block704 or the original block 702.

If the last written CBI sector turns out to be one of the four CBIsectors of the given logical group but is not exactly for the subgroupB, then its direct sector index is looked up to locate the CBI sectorfor the subgroup B. Once this exact CBI sector is located, its chaoticblock index is looked up to locate the ith logical sector among thechaotic update block 704 and the original block 702.

If the last written CBI sector turns out not to be anyone of the fourCBI sectors of the given logical group, its indirect sector index islooked up to locate one of the four. In the example shown in FIG. 16E,the CBI sector for subgroup C is located. Then this CBI sector forsubgroup C has its direct sector index looked up to locate the exact CBIsector for the subgroup B. The example shows that when its chaotic blockindex is looked up, the ith logical sector is found to be unchanged andit valid data will be located in the original block.

Similar consideration applies to locating the jth logical sector insubgroup C of the given logical group. The example shows that the lastwritten CBI sector turns out not to be any one of the four CBI sectorsof the given logical group. Its indirect sector index points to one ofthe four CBI sectors for the given group. The last written of fourpointed to also turns out to be exactly the CBI sector for the subgroupC. When its chaotic block index is looked up, the jth logical sector isfound to be located at a designated location in the chaotic update block704.

A list of chaotic sectors exists in controller RAM for each chaoticupdate block in the system. Each list contains a record of sectorswritten in the chaotic update block since a related CBI sector was lastupdated in flash memory. The number of logical sector addresses for aspecific chaotic update block, which can be held in a chaotic sectorlist, is a design parameter with a typical value of 8 to 16. The optimumsize of the list is determined as a tradeoff between its effects onoverhead for chaotic data-write operations and sector scanning timeduring initialization.

During system initialization, each chaotic update block is scanned asnecessary to identify valid sectors written since the previous update ofone of its associated CBI sectors. A chaotic sector list in controllerRAM for each chaotic update block is constructed. Each block need onlybe scanned from the last sector address defined in its chaotic blockinfo field in the last written CBI sector.

When a chaotic update block is allocated, a CBI sector is written tocorrespond to all updated logical sub-groups. The logical and physicaladdresses for the chaotic update block are written in an availablechaotic block info field in the sector, with null entries in the chaoticblock index field. A chaotic sector list is opened in controller RAM.

When a chaotic update block is closed, a CBI sector is written with thelogical and physical addresses of the block removed from the chaoticblock info field in the sector. The corresponding chaotic sector list inRAM becomes unused.

The corresponding chaotic sector list in controller RAM is modified toinclude records of sectors written to a chaotic update block. When achaotic sector list in controller RAM has no available space for recordsof further sector writes to a chaotic update block, updated CBI sectorsare written for logical sub-groups relating to sectors in the list, andthe list is cleared.

When the CBI block 620 becomes full, valid CBI sectors are copied to anallocated erased block, and the previous CBI block is erased.

Address Tables

The logical to physical address translation module 140 shown in FIG. 2is responsible for relating a host's logical address to a correspondingphysical address in flash memory. Mapping between logical groups andphysical groups (metablocks) are stored in a set of table and listsdistributed among the nonvolatile flash memory 200 and the volatile butmore agile RAM 130 (see FIG. 1.) An address table is maintained in flashmemory, containing a metablock address for every logical group in thememory system. In addition, logical to physical address records forrecently written sectors are temporarily held in RAM. These volatilerecords can be reconstructed from block lists and data sector headers inflash memory when the system is initialized after power-up. Thus, theaddress table in flash memory need be updated only infrequently, leadingto a low percentage of overhead write operations for control data.

The hierarchy of address records for logical groups includes the openupdate block list, the closed update block list in RAM and the groupaddress table (GAT) maintained in flash memory.

The open update block list is a list in controller RAM of data updateblocks which are currently open for writing updated host sector data.The entry for a block is moved to the closed update block list when theblock is closed. The closed update block list is a list in controllerRAM of data update blocks which have been closed. A subset of theentries in the list is moved to a sector in the Group Address Tableduring a control write operation.

The Group Address Table (GAT) is a list of metablock addresses for alllogical groups of host data in the memory system. The GAT contains oneentry for each logical group, ordered sequentially according to logicaladdress. The nth entry in the GAT contains the metablock address for thelogical group with address n. In the preferred embodiment, it is a tablein flash memory, comprising a set of sectors (referred to as GATsectors) with entries defining metablock addresses for every logicalgroup in the memory system. The GAT sectors are located in one or morededicated control blocks (referred to as GAT blocks) in flash memory.

FIG. 17A illustrates the data fields of a group address table (GAT)sector. A GAT sector may for example have sufficient capacity to containGAT entries for a set of 128 contiguous logical groups. Each GAT sectorincludes two components, namely a set of GAT entries for the metablockaddress of each logical group within a range, and a GAT sector index.The first component contains information for locating the metablockassociated with the logical address. The second component containsinformation for locating all valid GAT sectors within the GAT block.Each GAT entry has three fields, namely, the metablock number, the pagetag as defined earlier in connection with FIG. 3A(iii), and a flagindicating whether the metablock has been relinked. The GAT sector indexlists the positions of valid GAT sectors in a GAT block. This index isin every GAT sector but is superceded by the version of the next writtenGAT sector in the GAT block. Thus only the version in the last writtenGAT sector is valid.

FIG. 17B illustrates an example of the group address table (GAT) sectorsbeing recorded in one or more GAT block. A GAT block is a metablockdedicated to recording GAT sectors. When a GAT sector is updated, it iswritten in the next available physical sector location in the GAT block720. Multiple copies of a GAT sector may therefore exist in the GATblock, with only the last written copy being valid. For example the GATsector 255 (containing pointers for the logical groups LG₃₉₆₈-LG₄₀₉₈)has been updated at least two times with the latest version being thevalid one. The location of each valid sector in the GAT block isidentified by a set of indices in the last written GAT sector in theblock. In this example, the last written GAT sector in the block is GATsector 236 and its set of indices is the valid one superceding allprevious ones. When the GAT block eventually becomes fully filled withGAT sectors, the block is compacted during a control write operation byrewriting all valid sectors to a new block location. The full block isthen erased.

As described earlier, a GAT block contains entries for a logicallycontiguous set of groups in a region of logical address space. GATsectors within a GAT block each contain logical to physical mappinginformation for 128 contiguous logical groups. The number of GAT sectorsrequired to store entries for all logical groups within the addressrange spanned by a GAT block occupy only a fraction of the total sectorpositions in the block. A GAT sector may therefore be updated by writingit at the next available sector position in the block. An index of allvalid GAT sectors and their position in the GAT block is maintained inan index field in the most recently written GAT sector. The fraction ofthe total sectors in a GAT block occupied by valid GAT sectors is asystem design parameter, which is typically 25%. However, there is amaximum of 64 valid GAT sectors per GAT block. In systems with largelogical capacity, it may be necessary to store GAT sectors in more thanone GAT block. In this case, each GAT block is associated with a fixedrange of logical groups.

A GAT update is performed as part of a control write operation, which istriggered when the ABL runs out of blocks for allocation (see FIG. 18.)It is performed concurrently with ABL fill and CBL empty operations.During a GAT update operation, one GAT sector has entries updated withinformation from corresponding entries in the closed update block list.When a GAT entry is updated, any corresponding entries are removed fromthe closed update block list (CUBL). For example, the GAT sector to beupdated is selected on the basis of the first entry in the closed updateblock list. The updated sector is written to the next available sectorlocation in the GAT block.

A GAT rewrite operation occurs during a control write operation when nosector location is available for an updated GAT sector. A new GAT blockis allocated, and valid GAT sectors as defined by the GAT index arecopied in sequential order from the full GAT block. The full GAT blockis then erased.

A GAT cache is a copy in controller RAM 130 of entries in a subdivisionof the 128 entries in a GAT sector. The number of GAT cache entries is asystem design parameter, with typical value 32. A GAT cache for therelevant sector subdivision is created each time an entry is read from aGAT sector. Multiple GAT caches are maintained. The number is a designparameter with a typical value of 4. A GAT cache is overwritten withentries for a different sector subdivision on a least-recently-usedbasis.

Erased Metablock Management

The erase block manager 160 shown in FIG. 2 manages erase blocks using aset of lists for maintaining directory and system control information.These lists are distributed among the controller RAM 130 and flashmemory 200. When an erased metablock must be allocated for storage ofuser data, or for storage of system control data structures, the nextavailable metablock number in the allocation block list (ABL) (see FIG.15) held in controller RAM is selected. Similarly, when a metablock iserased after it has been retired, its number is added to a cleared blocklist (CBL) also held in controller RAM. Relatively static directory andsystem control data are stored in flash memory. These include erasedblock lists and a bitmap (MAP) listing the erased status of allmetablocks in the flash memory. The erased block lists and MAP arestored in individual sectors and are recorded to a dedicated metablock,known as a MAP block. These lists, distributed among the controller RAMand flash memory, provide a hierarchy of erased block records toefficiently manage erased metablock usage.

FIG. 18 is a schematic block diagram illustrating the distribution andflow of the control and directory information for usage and recycling oferased blocks. The control and directory data are maintained in listswhich are held either in controller RAM 130 or in a MAP block 750residing in flash memory 200.

In the preferred embodiment, the controller RAM 130 holds the allocationblock list (ABL) 610 and a cleared block list (CBL) 740. As describedearlier in connection with FIG. 15, the allocation block list (ABL)keeps track of which metablocks have recently been allocated for storageof user data, or for storage of system control data structures. When anew erased metablock need be allocated, the next available metablocknumber in the allocation block list (ABL) is selected. Similarly, thecleared block list (CBL) is used to keep track of update metablocks thathave been de-allocated and erased. The ABL and CBL are held incontroller RAM 130 (see FIG. 1) for speedy access and easy manipulationwhen tracking the relatively active update blocks.

The allocation block list (ABL) keeps track of a pool of erasedmetablocks and the allocation of the erased metablocks to be an updateblock. Thus, each of these metablocks that may be described by anattribute designating whether it is an erased block in the ABL pendingallocation, an open update block, or a closed update block. FIG. 18shows the ABL containing an erased ABL list 612, the open update blocklist 614 and the closed update block list 616. In addition, associatedwith the open update block list 614 is the associated original blocklist 615. Similarly, associated with the closed update block list is theassociated erased original block list 617. As shown previously in FIG.15, these associated lists are subset of the open update block list 614and the closed update block list 616 respectively. The erased ABL blocklist 612, the open update block list 614, and the closed update blocklist 616 are all subsets of the allocation block list (ABL) 610, theentries in each having respectively the corresponding attribute.

The MAP block 750 is a metablock dedicated to storing erase managementrecords in flash memory 200. The MAP block stores a time series of MAPblock sectors, with each MAP sector being either an erase blockmanagement (EBM) sector 760 or a MAP sector 780. As erased blocks areused up in allocation and recycled when a metablock is retired, theassociated control and directory data is preferably contained in alogical sector which may be updated in the MAP block, with each instanceof update data being recorded to a new block sector. Multiple copies ofEBM sectors 760 and MAP sectors 780 may exist in the MAP block 750, withonly the latest version being valid. An index to the positions of validMAP sectors is contained in a field in the EMB block. A valid EMB sectoris always written last in the MAP block during a control writeoperation. When the MAP block 750 is full, it is compacted during acontrol write operation by rewriting all valid sectors to a new blocklocation. The full block is then erased.

Each EBM sector 760 contains erased block lists (EBL) 770, which arelists of addresses of a subset of the population of erased blocks. Theerased block lists (EBL) 770 act as a buffer containing erased metablocknumbers, from which metablock numbers are periodically taken to re-fillthe ABL, and to which metablock numbers are periodically added tore-empty the CBL. The EBL 770 serves as buffers for the available blockbuffer (ABB) 772, the erased block buffer (EBB) 774 and the clearedblock buffer (CBB) 776.

The available block buffer (ABB) 772 contains a copy of the entries inthe ABL 610 immediately following the previous ABL fill operation. It isin effect a backup copy of the ABL just after an ABL fill operation.

The erased block buffer (EBB) 774 contains erased block addresses whichhave been previously transferred either from MAP sectors 780 or from theCBB list 776 (described below), and which are available for transfer tothe ABL 610 during an ABL fill operation.

The cleared block buffer (CBB) 776 contains addresses of erased blockswhich have been transferred from the CBL 740 during a CBL emptyoperation and which will be subsequently transferred to MAP sectors 780or to the EBB list 774.

Each of the MAP sectors 780 contains a bitmap structure referred to asMAP. The MAP uses one bit for each metablock in flash memory, which isused to indicate the erase status of each block. Bits corresponding toblock addresses listed in the ABL, CBL, or erased block lists in the EBMsector are not set to the erased state in the MAP.

Any block which does not contain valid data structures and which is notdesignated as an erased block within the MAP, erased block lists, ABL orCBL is never used by the block allocation algorithm and is thereforeinaccessible for storage of host or control data structures. Thisprovides a simple mechanism for excluding blocks with defectivelocations from the accessible flash memory address space.

The hierarchy shown in FIG. 18 allows erased block records to be managedefficiently and provides full security of the block address lists storedin the controller's RAM. Erased block entries are exchanged betweenthese block address lists and one or more MAP sectors 780, on aninfrequent basis. These lists may be reconstructed during systeminitialization after a power-down, via information in the erased blocklists and address translation tables stored in sectors in flash memory,and limited scanning of a small number of referenced data blocks inflash memory.

The algorithms adopted for updating the hierarchy of erased metablockrecords results in erased blocks being allocated for use in an orderwhich interleaves bursts of blocks in address order from the MAP block750 with bursts of block addresses from the CBL 740 which reflect theorder blocks were updated by the host. For most metablock sizes andsystem memory capacities, a single MAP sector can provide a bitmap forall metablocks in the system. In this case, erased blocks are alwaysallocated for use in address order as recorded in this MAP sector.

Erase Block Management Operations

As described earlier, the ABL 610 is a list with address entries forerased metablocks which may be allocated for use, and metablocks whichhave recently been allocated as data update blocks. The actual number ofblock addresses in the ABL lies between maximum and minimum limits,which are system design variables. The number of ABL entries formattedduring manufacturing is a function of the card type and capacity. Inaddition, the number of entries in the ABL may be reduced near the endof life of the system, as the number of available erased blocks isreduced by failure of blocks during life. For example, after a filloperation, entries in the ABL may designate blocks available for thefollowing purposes. Entries for Partially written data update blockswith one entry per block, not exceeding a system limit for a maximum ofconcurrently opened update blocks. Between one to twenty entries forErased blocks for allocation as data update blocks. Four entries forerased blocks for allocation as control blocks.

ABL Fill Operation

As the ABL 610 becomes depleted through allocations, it will need to berefilled. An operation to fill the ABL occurs during a control writeoperation. This is triggered when a block must be allocated, but the ABLcontains insufficient erased block entries available for allocation as adata update block, or for some other control data update block. During acontrol write, the ABL fill operation is concurrent with a GAT updateoperation.

The following actions occur during an ABL fill operation.

1. ABL entries with attributes of current data update blocks areretained.

2. ABL entries with attributes of closed data update blocks areretained, unless an entry for the block is being written in theconcurrent GAT update operation, in which case the entry is removed fromthe ABL.

3. ABL entries for unallocated erase blocks are retained.

4. The ABL is compacted to remove gaps created by removal of entries,maintaining the order of entries.

5. The ABL is completely filled by appending the next available entriesfrom the EBB list.

6. The ABB list is over-written with the current entries in the ABL.

CBL Empty Operation

The CBL is a list of erased block addresses in controller RAM with thesame limitation on the number of erased block entries as the ABL. Anoperation to empty the CBL occurs during a control write operation. Itis therefore concurrent with an ABL fill/GAT update operations, or CBIblock write operations. In a CBL empty operation, entries are removedfrom the CBL 740 and written to the CBB list 776.

MAP Exchange Operation

A MAP exchange operation between the erase block information in the MAPsectors 780 and the EBM sectors 760 may occur periodically during acontrol write operation, when the EBB list 774 is empty. If all erasedmetablocks in the system are recorded in the EBM sector 760, no MAPsector 780 exists and no MAP exchange is performed. During a MAPexchange operation, a MAP sector feeding the EBB 774 with erased blocksis regarded as a source MAP sector 782. Conversely, a MAP sectorreceiving erased blocks from the CBB 776 is regarded as a destinationMAP sector 784. If only one MAP sector exists, it acts as both sourceand destination MAP sector, as defined below.

The following actions are performed during a MAP exchange.

1. A source MAP sector is selected, on the basis of an incrementalpointer.

2. A destination MAP sector is selected, on the basis of the blockaddress in the first CBB entry that is not in the source MAP sector.

3. The destination MAP sector is updated, as defined by relevant entriesin the CBB, and the entries are removed from the CBB.

4. The updated destination MAP sector is written in the MAP block,unless no separate source MAP sector exists.

5. The source MAP sector is updated, as defined by relevant entries inthe CBB, and the entries are removed from the CBB.

6. Remaining entries in the CBB are appended to the EBB.

7. The EBB is filled to the extent possible with erased block addressesdefined from the source MAP sector.

8. The updated source MAP sector is written in the MAP block.

9. An updated EBM sector is written in the MAP block.

List Management

FIG. 18 shows the distribution and flow of the control and directoryinformation between the various lists. For expediency, operations tomove entries between elements of the lists or to change the attributesof entries, identified in FIG. 18 as [A] to [O], are as follows.

[A] When an erased block is allocated as an update block for host data,the attributes of its entry in the ABL are changed from Erased ABL Blockto Open Update Block. [B] When an erased block is allocated as a controlblock, its entry in the ABL is removed.

[C] When an ABL entry is created with Open Update Block attributes, anAssociated Original Block field is added to the entry to record theoriginal metablock address for the logical group being updated. Thisinformation is obtained from the GAT.

[D] When an update block is closed, the attributes of its entry in theABL are changed from Open Update Block to Closed Update Block. [E] Whenan update block is closed, its associated original block is erased andthe attributes of the Associated Original Block field in its entry inthe ABL are changed to Erased Original Block. [F] During an ABL filloperation, any closed update block whose address is updated in the GATduring the same control write operation has its entry removed from theABL. [G] During an ABL fill operation, when an entry for a closed updateblock is removed from the ABL, an entry for its associated erasedoriginal block is moved to the CBL. [H] When a control block is erased,an entry for it is added to the CBL. [I] During an ABL fill operation,erased block entries are moved to the ABL from the EBB list, and aregiven attributes of Erased ABL Blocks. [J] After modification of allrelevant ABL entries during an ABL fill operation, the block addressesin the ABL replace the block addresses in the ABB list. [K] Concurrentlywith an ABL fill operation during a control write, entries for erasedblocks in the CBL are moved to the CBB list. [L] During a MAP exchangeoperation, all relevant entries are moved from the CBB list to the MAPdestination sector. [M] During a MAP exchange operation, all relevantentries are moved from the CBB list to the MAP source sector. [N]Subsequent to [L] and [M] during a MAP exchange operation, all remainingentries are moved from the CBB list to the EBB list. [O] Subsequent to[N] during a MAP exchange operation, entries other than those moved in[M] are moved from the MAP source sector to fill the EBB list, ifpossible. Logical to Physical Address Translation

To locate a logical sector's physical location in flash memory, thelogical to physical address translation module 140 shown in FIG. 2performs a logical to physical address translation. Except for thoselogical groups that have recently been updated, the bulk of thetranslation could be performed using the group address table (GAT)residing in the flash memory 200 or the GAT cache in controller RAM 130.Address translations for the recently updated logical groups willrequire looking up address lists for update blocks which reside mainlyin controller RAM 130. The process for logical to physical addresstranslation for a logical sector address is therefore dependent on thetype of block associated with the logical group within which the sectoris located. The types of blocks are: intact block, sequential dataupdate block, chaotic data update block, closed data update block.

FIG. 19 is a flow chart showing the process of logical to physicaladdress translation. Essentially, the corresponding metablock and thephysical sector is located by using the logical sector address first tolookup the various update directories such as the open update block listand the close update block list. If the associated metablock is not partof an update process, then directory information is provided by the GAT.The logical to physical address translation includes the followingsteps:

STEP 800: A logical sector address is given.

STEP 810: Look up given logical address in the open update blocks list614 (see FIGS. 15 and 18) in controller RAM. If lookup fails, proceed toSTEP 820, otherwise proceed to STEP 830.

STEP 820: Look up given logical address in the closed update block list616. If lookup fails, the given logical address is not part of anyupdate process; proceed to STEP 870 for GAT address translation.Otherwise proceed to STEP 860 for closed update block addresstranslation.

STEP 830: If the update block containing the given logical address issequential, proceed to STEP 840 for sequential update block addresstranslation. Otherwise proceed to STEP 850 for chaotic update blockaddress translation.

STEP 840: Obtain the metablock address using sequential update blockaddress translation. Proceed to STEP 880.

STEP 850: Obtain the metablock address using chaotic update blockaddress translation. Proceed to STEP 880.

STEP 860: Obtain the metablock address using closed update block addresstranslation. Proceed to STEP 880.

STEP 870: Obtain the metablock address using group address table (GAT)translation. Proceed to STEP 880.

STEP 880: Convert the Metablock Address to a physical address. Thetranslation method depends on whether the metablock has been relinked.

STEP 890: Physical sector address obtained.

The various address translation processes are described in more detailas follows:

Sequential Update Block Address Translation (STEP 840)

Address translation for a target logical sector address in a logicalgroup associated with a sequential update block can be accomplisheddirectly from information in the open update block list 614 (FIGS. 15and 18), as follows.

1. It is determined from the “page tag” and “number of sectors written”fields in the list whether the target logical sector is located in theupdate block or its associated original block. 2. The metablock addressappropriate to the target logical sector is read from the list. 3. Thesector address within the metablock is determined from the appropriate“page tag” field. Chaotic Update Block Address Translation (STEP 850)

The address translation sequence for a target logical sector address ina logical group associated with a chaotic update block is as follows.

1. If it is determined from the chaotic sector list in RAM that thesector is a recently written sector, address translation may beaccomplished directly from its position in this list.

2. The most recently written sector in the CBI block contains, withinits chaotic block data field, the physical address of the chaotic updateblock relevant to the target logical sector address. It also contains,within its indirect sector index field, the offset within the CBI blockof the last written CBI sector relating to this chaotic update block(see FIGS. 16A-16E).

3. The information in these fields is cached in RAM, eliminating theneed to read the sector during subsequent address translation.

4. The CBI sector identified by the indirect sector index field at step3 is read.

5. The direct sector index field for the most recently accessed chaoticupdate sub-group is cached in RAM, eliminating the need to perform theread at step 4 for repeated accesses to the same chaotic update block.

6. The direct sector index field read at step 4 or step 5 identifies inturn the CBI sector relating to the logical sub-group containing thetarget logical sector address.

7. The chaotic block index entry for the target logical sector addressis read from the CBI sector identified in step 6.

8. The most recently read chaotic block index field may be cached incontroller RAM, eliminating the need to perform the reads at step 4 andstep 7 for repeated accesses to the same logical sub-group.

9. The chaotic block index entry defines the location of the targetlogical sector either in the chaotic update block or in the associatedoriginal block. If the valid copy of the target logical sector is in theoriginal block, it is located by use of the original metablock and pagetag information.

Closed Update Block Address Translation (STEP 860)

Address translation for a target logical sector address in a logicalgroup associated with a closed update block can be accomplished directlyfrom information in the closed block update list (see FIG. 18), asfollows.

1. The metablock address assigned to the target logical group is readfrom the list.

2. The sector address within the metablock is determined from the “pagetag” field in the list.

GAT Address Translation (STEP 870)

If a logical group is not referenced by either the open or closed blockupdate lists, its entry in the GAT is valid. The address translationsequence for a target logical sector address in a logical groupreferenced by the GAT is as follows.

1. The ranges of the available GAT caches in RAM are evaluated todetermine if an entry for the target logical group is contained in a GATcache.

2. If the target logical group is found in step 1, the GAT cachecontains full group address information, including both metablockaddress and page tag, allowing translation of the target logical sectoraddress.

3. If the target address is not in a GAT cache, the GAT index must beread for the target GAT block, to identify the location of the GATsector relating to the target logical group address.

4. The GAT index for the last accessed GAT block is held in controllerRAM, and may be accessed without need to read a sector from flashmemory.

5. A list of metablock addresses for every GAT block, and the number ofsectors written in each GAT block, is held in controller RAM. If therequired GAT index is not available at step 4, it may therefore be readimmediately from flash memory.

6. The GAT sector relating to the target logical group address is readfrom the sector location in the GAT block defined by the GAT indexobtained at step 4 or step 6. A GAT cache is updated with thesubdivision of the sector containing the target entry.

7. The target sector address is obtained from the metablock address and“page tag” fields within the target GAT entry.

Metablock to Physical Address Translation (STEP 880)

If a flag associated with the metablock address indicates that themetablock has been re-linked, the relevant LT sector is read from theBLM block, to determine the erase block address for the target sectoraddress. Otherwise, the erase block address is determined directly fromthe metablock address.

Control Data Management

FIG. 20 illustrates the hierarchy of the operations performed on controldata structures in the course of the operation of the memory management.Data Update Management Operations act on the various lists that residein RAM. Control write operations act on the various control data sectorsand dedicated blocks in flash memory and also exchange data with thelists in RAM.

Data update management operations are performed in RAM on the ABL, theCBL and the chaotic sector list. The ABL is updated when an erased blockis allocated as an update block or a control block, or when an updateblock is closed. The CBL is updated when a control block is erased orwhen an entry for a closed update block is written to the GAT. Theupdate chaotic sector list is updated when a sector is written to achaotic update block.

A control write operation causes information from control datastructures in RAM to be written to control data structures in flashmemory, with consequent update of other supporting control datastructures in flash memory and RAM, if necessary. It is triggered eitherwhen the ABL contains no further entries for erased blocks to beallocated as update blocks, or when the CBI block is rewritten.

In the preferred embodiment, the ABL fill operation, the CBL emptyoperation and the EBM sector update operation are performed during everycontrol write operation. When the MAP block containing the EBM sectorbecomes full, valid EBM and MAP sectors are copied to an allocatederased block, and the previous MAP block is erased.

One GAT sector is written, and the Closed Update Block List is modifiedaccordingly, during every control write operation. When a GAT blockbecomes full, a GAT rewrite operation is performed.

A CBI sector is written, as described earlier, after certain chaoticsector write operations. When the CBI block becomes full, valid CBIsectors are copied to an allocated erased block, and the previous CBIblock is erased.

A MAP exchange operation, as described earlier, is performed when thereare no further erased block entries in the EBB list in the EBM sector.

A MAP Address (MAPA) sector, which records the current address of theMAP block, is written in a dedicated MAPA block on each occasion the MAPblock is rewritten. When the MAPA block becomes full, the valid MAPAsector is copied to an allocated erased block, and the previous MAPAblock is erased.

A Boot sector is written in a current Boot block on each occasion theMAPA block is rewritten. When the boot block becomes full, the validBoot sector is copied from the current version of the Boot block to thebackup version, which then becomes the current version. The previouscurrent version is erased and becomes the backup version, and the validBoot sector is written back to it.

Control Data Integrity & Management

Example of control data are the directory information and blockallocation information associated with the memory block managementsystem, such as those described in connection with FIG. 20. As describedearlier, the control data is maintained in both high speed RAM and theslower nonvolatile memory blocks. Any frequently changing control datais maintained in RAM with periodic control writes to update equivalentinformation stored in a nonvolatile metablock. In this way, the controldata is stored in nonvolatile, but slower flash memory without the needfor frequent access. A hierarchy of control data structures such as GAT,CBI, MAP, and MAPA shown in FIG. 20 is maintained in flash memory. Thus,a control write operation causes information from control datastructures in RAM to update equivalent control data structures in flashmemory.

As described in connection with FIG. 20, the block management systemmaintains a set of control data in flash memory during its operation.This set of control data is stored in the metablocks similar to hostdata. As such, the control data itself will be block managed and will besubject to updates and therefore garbage collection operations.

It has also been described that a hierarchy of control data exists, withthe ones in the lower hierarchy being updated more often than thosehigher up. For example, assuming that every control block has N controlsectors to write, the following sequence of control updates and controlblock relocations, normally happens. Referring to FIG. 20 again, every NCBI updates fill up the CBI block and trigger a CBI relocation (rewrite)and a MAP update. If the Chaotic block gets closed then it also triggersGAT update. Every GAT update triggers a MAP update. Every N GAT updatesfill up the block and trigger a GAT block relocation. In addition, whena MAP block gets full it also triggers a MAP block relocation and a MAPABlock (if exist, otherwise BOOT block points directly to MAP) update. Inaddition, when a MAPA block gets full, it also triggers a MAPA blockrelocation, a BOOT Block update and a MAP update. In addition, when aBOOT Block gets full, it triggers an active BOOT Block relocation toanother BOOT Block.

Update Block Replacement Scheme

According to another aspect of the invention, in a nonvolatile memorywith a block management system, an improved block replacement scheme isimplemented for a system supporting up to a first predetermined maximumnumber of update blocks that are concurrently opened for recording data.The update blocks are mainly sequential update blocks where data arerecorded in logically sequential order but up to a second predeterminedmaximum number of which are allowed to be chaotic update blocks wheredata are not recorded in logically sequential order. Whenever a newallocation of an update block may cause the pool of update blocks toexceed either the first or second predetermined maximum number, one ofthe existing update blocks in the pool will be closed and removed inorder to comply with the limitation. Prior to closing the update block,its data are consolidated into a sequential block. The improved schemeis to avoid the situation where a sequential update can cause anexcessive number of chaotic block consolidations. This is accomplishedby separating sequential update blocks and chaotic update blocks intorespective replacement or consolation pools. In particular, when asequential update causes the allocation of a new update block to exceedthe first predetermined maximum number, a least recently used sequentialupdate block of the pool is preferentially to make room.

In the current system, generally there are two types of data: user dataand control data. The user data are sent from a host to the memorysystem typically in logical sequential order. Sequential update blocksare allocated to optimally handle sequential write operations from thehost. The user data can also be in logically non-sequential orderespecially when there are subsequent updates to the logical data.Chaotic update blocks are created to optimally handle the data innon-sequential order. Another source of chaotic or non-sequential datais control data maintained by the file system or memory system such asfile and directory information which are generated in the course ofstoring user data.

Previous scheme of complying to a practical system limitation ofsupporting up to a maximum number of concurrently opened update blockshas been to close the least recently used update block in the pool,irrespective of whether it is sequential or chaotic.

The present scheme improves over the previous scheme where essentially,if during a sequential write operation an update block among a poolthereof needs to be closed to make room for a new allocation, the leastrecently used sequential update block in the pool is closed. Thisensures the various update blocks are effectively used to handlesequential write operations and random write operations. In particular,it avoids the inefficient situation where a large sequential writeoperation by the host may force a premature closure of a chaotic updateblock containing FAT and Directory information. Another chaotic blockwill in effect be created very soon to store the FAT and Directoryinformation which will be updated again once the large sequential writeoperation is done. The creation of the improved replacement policymandates separation of the replacement and consolidation pool to preventthe added overhead in consolidating the chaotic block during sequentialwrite and consolidation of potentially an open sequential or an openchaotic block to manage the subsequent FAT and Directory update.

The practical system limitation of supporting up to a maximum number ofconcurrently opened update blocks has been described earlier. Forexample, in one embodiment described in connection with FIG. 10, STEP410 tests if a new allocation will exceed the maximum number U_(MAX) ofupdate blocks that can be concurrently opened for accepting update data.If U_(MAX) will be exceeded, the least active among the update blocks,irrespective of whether it is a sequential or chaotic update block, willbe closed in STEP 420 to keep the system within the prescribed limit.

FIG. 21 illustrates schematically the two prescribed limits on thenumber of update blocks for a block managing system. There is an overalllimit in the total number of update blocks (U_(MAX)), which is given bythe sum of the number of chaotic update blocks N_(C) and the number ofsequential update blocks N_(S). Since a chaotic update block is moreresource-intensive, requiring additional maintenance of a chaotic blockindex (CBI), preferably there is also a limit on the maximum number ofchaotic update blocks (“U_(CMAX)”). Thus, the first limit requires thatthe total number of update blocks, N_(C)+N_(S)<=U_(MAX). The secondlimit requires that the number of chaotic update blocks N_(C)<=U_(CMAX).

FIG. 22 illustrates typical examples of combinations of the two limitsoptimized for various memory devices. A given combination is designatedby U_(MAX) “dash” U_(CMAX). For example, “3-1” designates a blockmanaging system allowing up to a maximum of three update blocks in theupdate pool and of which only up to one is a chaotic update block.Similarly, “7-3” designates a block managing system supporting up to amaximum of seven update blocks and of which up to three can be chaoticupdate blocks. In general simpler memory systems having smaller memorycapacity will be more restrictive, having smaller maximum numbers.

FIG. 23A, FIG. 23B and FIG. 23C illustrate schematically the sequence ofevent for introducing a new update block into a pool of update blocks,according to a first situation in a previous replacement scheme.

FIG. 23A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22. In this example, the update poolis fully populated with a maximum of five allowable update blocks. Theupdate pool is further partitioned into a sequential pool 1200 thatcontains three sequential update blocks, S1, S2 and S3 and a chaoticpool 1300 that contains a maximum of two chaotic or non-sequentialupdate blocks, C4 and C5. The example shows a first situation in whichthe least active block happens to be a sequential update block such asS3 1201.

In the event that a new update block needs to be allocated, one of theexisting update blocks in the update pool will need to be closed to makeroom. For example in the event when the host writes sequential data fora logical group of sectors not serviced by the existing update blocks inthe pool, a new update block will need to be allocated for recording thedata.

FIG. 23B illustrates schematically the closing of the least activeupdate block in order to make room for a new update block, according tothe previous scheme. The least active update block, in this case happensto be S3 1201 and it will be closed and removed from the pool of theupdate blocks.

FIG. 23C illustrates schematically introducing a newly allocated updateblock into the pool after a closed update block has been removed to makeroom. In this case, S6 1212 which is a newly allocated update block willbe introduced into the sequential pool 1200 for recording data inlogically sequential order. In this way, U_(MAX), the maximum number ofupdate blocks allowed is not exceeded.

FIG. 24A, FIG. 24B and FIG. 24C illustrate schematically the sequence ofevent for introducing a new update block into a pool of update blocks,according to a second situation in the previous replacement scheme.

FIG. 24A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22. In this example, the update poolis fully populated with a maximum of five allowable update blocks. Theupdate pool is further partitioned into a sequential pool 1200 thatcontains three sequential update blocks, S1, S2 and S3 and a chaoticpool 1300 that contains a maximum of two chaotic or non-sequentialupdate blocks, C4 and C5. The example shows a second situation in whichthe least active block happens to be a chaotic update block such as C41301.

FIG. 24B illustrates schematically the closing of the least activeupdate block in order to make room for a new update block, according tothe previous scheme. The least active update block, in this case is C41301 and it will be closed and removed from the pool of the updateblocks.

FIG. 24C illustrates schematically introducing a newly allocated updateblock into the pool after a closed update block has been removed to makeroom. In this case, S6 1212 which is a newly allocated update block willbe introduced into the sequential pool 1200 for recording data inlogically sequential order. In this way, U_(MAX), the maximum number ofupdate blocks allowed is not exceeded.

FIG. 25A and FIG. 25B, respectively illustrate the maintenance of theU_(MAX) and U_(CMAX) limitation in the scheme previously described inFIG. 10, FIG. 23B and FIG. 24B. The two limitations are typicallyimposed at the same time.

FIG. 25A illustrates the scheme previously illustrated in FIG. 10, STEP410 and also in FIG. 23B and FIG. 24B where the least recently accessedupdate block is closed whenever a new allocation would exceed apredetermined limit.

STEP 1252: Organizing a nonvolatile memory into blocks, each block forstoring data that are erasable together.

STEP 1254: Allocating up to a first predetermined number of updateblocks that are concurrently open for storing updates of logical unitsof data.

STEP 1256: Whenever allocating a new update block would exceed thepredetermined number, closing one of the least recently accessed updateblocks to make room for the new update block.

FIG. 25B illustrates the scheme previously illustrated in FIG. 10, STEP370 where the least recently accessed chaotic (non-sequential) updateblock is closed whenever the number of chaotic update blocks exceeds apredetermined limit.

STEP 1354: Allocating up to a second predetermined number of updateblocks among the opened update blocks for storing logical units of datain logically non-sequential order.

STEP 1356: Whenever the number of non-sequential update blocks wouldexceed the second predetermined number, closing one of the leastrecently accessed non-sequential update blocks so as not to exceed thesecond predetermined number.

One disadvantage of this previous scheme is that it can under somecircumstances lead to excessive closure of chaotic update blocks. It isparticularly inefficient in the case when a sequential write causes achaotic block containing control data to be prematurely closed-out tomake room in the pool for a newly allocated sequential block. Forexample, if the closed-out chaotic update block, C4 1310, was recordingFAT and Directory information, a replacement will immediately need to beallocated to serve that function as soon as the sequential write isdone. This would entail yet another round of closure of the least activeupdate block currently in the pool in order to make room for thereplacement update block for recording control data.

According to the current aspect of the invention, the closure of anupdate block so as not to exceed a predetermined maximum number ofupdate blocks is further refined from merely selecting the leastrecently used update blocks to a scheme that reduces the instance ofexcessive closure of chaotic update blocks. In a preferred embodiment,if an update block is allocate to record sequential data and one in apool of update blocks needs to be closed to make room, the least activesequential update block in the pool is closed.

FIG. 26A, FIG. 26B and FIG. 26C illustrate schematically the sequence ofevent for introducing a new update block into a pool of update blocks,according to the present improved replacement scheme.

FIG. 26A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22. In this example, the update poolis fully populated with a maximum of five allowable update blocks. Theupdate pool is further partitioned into a sequential pool 1200 thatcontains three sequential update blocks, S1, S2 and S3 and a chaoticpool 1300 that contains a maximum of two chaotic or non-sequentialupdate blocks, C4 and C5. The example shows a similar situation as inFIG. 24A in which the least active block happens to be a chaotic updateblock such as C4 1301. Furthermore it shows the sequential block S3 1202as being the least active in the sequential pool 1200.

FIG. 26B illustrates schematically the closing of one among the pool ofan update blocks in order to make room for a new update block, accordingto the present improved scheme. In the event of a new allocationassociated with a sequential update and the number of update blocks inthe pool is already at a maximum, one of the update blocks in the poolwill have to be closed out to make room for the newly allocated updateblock. However, in this case the least active block is C4 1301, andbecause it is a chaotic block, it will be passed over. Instead, theleast active update block in the sequential pool 1200 will be closedout. In this example, it is S3 1202 that will be closed out and removedfrom the update block pool.

FIG. 26C illustrates schematically introducing a newly allocated updateblock into the pool after a closed update block has been removed to makeroom. In this case, S6 1212 which is a newly allocated update block willbe introduced into the sequential pool 1200 for recording data inlogically sequential order. In this way, U_(MAX), the maximum number ofupdate blocks allowed is not exceeded.

FIG. 27A, FIG. 27B and FIG. 27C illustrate schematically the sequence ofevent for introducing a new chaotic update block into a pool of updateblocks, according to the present improved replacement scheme.

FIG. 27A illustrates schematically an update pool with a “5-2”configuration as described in FIG. 22. In this example, the update poolis fully populated with a maximum of five allowable update blocks. Theupdate pool is further partitioned into a sequential pool 1200 thatcontains three sequential update blocks, S1, S2 and S3 and a chaoticpool 1300 that contains a maximum of two chaotic or non-sequentialupdate blocks, C4 and C5. The example shows that the least active blockhappens to be a sequential update block such as S6 1201. Furthermore itshows the chaotic block C4 1302 as being the least active in the chaoticpool 1300.

FIG. 27B illustrates schematically the closing of one among the pool ofan update blocks in order to make room for a new update block, accordingto the present improved scheme. In the event of a new chaotic updateblock being introduced into an already full chaotic pool 1300, one ofthe update blocks in the chaotic pool will have to be closed out to makeroom. In the example, the chaotic pool 1300 already contains a maximumof two chaotic update blocks. When, another chaotic update block iscreated, as for example when an existing sequential update block S1 1220has be converted to a chaotic block, the maximum number of chaoticblocks would be exceeded unless one of them is removed. In this case theleast active chaotic block C4 1302 is closed out and removed from thechaotic pool 1300 to make room.

FIG. 27C illustrates schematically introducing a new chaotic updateblock into the pool after another chaotic update block has been closedand removed to make room. In this case, S1 which has been converted froma sequential update block 1220 in the sequential pool 1200 to a chaoticupdate block C6 1320 in the chaotic pool 1300. In this way, U_(CMAX),the maximum number of chaotic update blocks allowed is not exceeded.

FIG. 28 is a flow chart illustrating the present improved scheme ofmanaging a limited set of update blocks during a sequential update,according to a first embodiment.

STEP 1400: Organizing a nonvolatile memory into blocks, each block forstoring data that are erasable together.

STEP 1402: Allocating up to a first predetermined number of updateblocks that are concurrently open for storing updates of logical unitsof data

STEP 1406: Responsive to a write command to write sequential data,writing logical units of data in sequential order onto an update block.

STEP 1408: Responsive to a predetermined condition being satisfied forthe update block to be closed to further writing of the sequentiallogical units of data, allocating a new update block to continue thewriting, and if the new allocation would exceed the first predeterminednumber, preferentially closing a least recently accessed update block insequential order over any least recently accessed update block innon-sequential order.

FIG. 29 is a flow chart illustrating the present improved scheme ofmanaging a limited set of update blocks having two predetermined limits,according to a second embodiment.

STEP 1410: Organizing a nonvolatile memory into blocks, each block forstoring data that are erasable together.

STEP 1412: Allocating up to a first predetermined number of updateblocks that are concurrently open for storing updates of logical unitsof data.

STEP 1416: Allocating up to a second predetermined number of updateblocks among the opened update blocks for storing logical units of datain logically non-sequential order.

STEP 1418: Whenever introduction of an update block for storing data inlogically sequential order may exceed the first predetermined number,closing a least recently accessed update blocks containing data inlogically sequential order to make room for the introduced update block.

STEP 1420: Whenever introduction of an update block for storing data inlogically non-sequential order may exceed the second predeterminednumber, closing a least recently accessed update blocks containing datain logically non-sequential order to make room for the introduced updateblock.

A generalization of the present scheme is to classify the update blocksbased on a set of attributes, such as whether the update block isstoring sequential or non-sequential data or whether it is storing somepredefined type of system data. In implementing a pool of update blocksof limited number, each class of update blocks will have its own rulefor replacement when the maximum number supported for that class will beexceeded.

For example, sequential update block and non-sequential update blocksare two different classes. The replacement rules for each of theseclasses are the same, namely to replace a least active one with a newone. Thus, when the pool of sequential update blocks will be exceeded, aleast active one in the pool will be closed and removed before a new oneis introduced to the pool. Similarly for the pool of non-sequentialupdate blocks.

In general each class has its own replacement rule independent of theother classes. Examples of replacement rules are to replace the leastrecently accessed, the most recently accessed, the least frequentlyaccessed, the most frequently accessed, etc, depending on thecorresponding classes.

FIG. 30 is a flow chart illustrating the present improved scheme ofmanaging a limited set of update blocks having class-based replacementrules.

STEP 1430: Organizing a nonvolatile memory into blocks, each block forstoring data that are erasable together.

STEP 1432: Providing a pool of up to a first predetermined maximumnumber of update blocks that are concurrently open for storing updatesof logical units of data.

STEP 1436: Providing a set of predefined classes for classifying updateblocks based on a set of attributes, with each class supporting asub-pool of up to an associated predetermined maximum number of updateblocks;

STEP 1438: Providing a set of corresponding replacement rules to the setof predefined classes to specify the update block in the respectivesub-pools to be replaced.

STEP 1438: Grouping the update blocks in the pool by class intocorresponding sub-pools.

STEP 1440: Closing and removing a least active update block in asub-pool containing the associated predetermined maximum number ofupdate blocks whenever another update block of the same class is beingintroduced thereto.

All patents, patent applications, articles, books, specifications, otherpublications, documents and things referenced herein are herebyincorporated herein by this reference in their entirety for allpurposes. To the extent of any inconsistency or conflict in thedefinition or use of a term between any of the incorporatedpublications, documents or things and the text of the present document,the definition or use of the term in the present document shall prevail.

Although the various aspects of the present invention have beendescribed with respect to certain embodiments, it is understood that theinvention is entitled to protection within the full scope of theappended claims.

1. In a non-volatile memory organized into a plurality of blocks, each block for storing logical units of data that are erasable together, a method of storing data in the memory, comprising: allocating up to a first predetermined number of blocks as update blocks that are concurrently open for storing updates of logical units of data; responsive to a write command to write data that is in logically sequential order, writing data onto an update block in logically sequential order; and responsive to a predetermined condition being satisfied for the update block to be closed to further writing of the sequential logical units of data, allocating a new update block to continue the writing, and if the new allocation would exceed the first predetermined number, preferentially closing a least recently accessed update block storing data in sequential order over any least recently accessed one storing data in non-sequential order.
 2. In a non-volatile memory organized into a plurality of blocks, each block for storing logical units of data that are erasable together, a method of storing data in the memory, comprising: allocating up to a first predetermined number of blocks as update blocks that are concurrently open for storing updates of logical units of data; allocating up to a second predetermined number of update blocks among the opened update blocks for storing logical units of data in logically non-sequential order; whenever introduction of an update block for storing data in logically sequential order may exceed the first predetermined number, closing a least recently accessed update blocks containing data in logically sequential order to make room for the introduced update block; and whenever introduction of an update block for storing data in logically non-sequential order may exceed the second predetermined number, closing a least recently accessed update blocks containing data in logically non-sequential order to make room for the introduced update block.
 3. The method as in claim 2, wherein the update block for storing data in logically non-sequential order was converted from one storing data in logically sequential order.
 4. In a non-volatile memory organized into a plurality of blocks, each block for storing logical units of data that are erasable together, a method of storing data in the memory, comprising: allocating up to a first predetermined number of blocks as update blocks that are concurrently open for storing updates of logical units of data; providing a pool of up to a first predetermined maximum number of update blocks that are concurrently open for storing updates of logical units of data; providing a set of predefined classes for classifying update blocks based on a set of attributes, with each class supporting a sub-pool of up to an associated predetermined maximum number of update blocks; providing a set of corresponding replacement rules to the set of predefined classes to specify the update block in the respective sub-pools to be replaced; grouping the update blocks in the pool by class into corresponding sub-pools; and closing and removing a least active update block in a sub-pool containing the associated predetermined maximum number of update blocks whenever another update block of the same class is being introduced thereto, the removed update block being selected in accordance with the corresponding replacement rule for the same class.
 5. The method as in claim 4, wherein the set attributes includes a block storing data in logically sequential order.
 6. The method as in claim 4, wherein the set attributes includes a block storing data in logically non-sequential order.
 7. The method as in claim 4, wherein the set attributes includes a block storing system data associated with operating the memory.
 8. The method as in claim 4, wherein the memory is a flash EEPROM.
 9. The method as in claim 4, wherein the memory has a NAND structure.
 10. The method as in claim 4, wherein the memory is on a removable memory card.
 11. The method as in claim 4, wherein the non-volatile memory has memory cells with a floating gate structure.
 12. The method as in claim 4, wherein the non-volatile memory has memory cells with a dielectric layer structure.
 13. The method as in any one of claims 1-12, wherein the memory has memory cells that each stores one bit of data.
 14. The method as in any one of claims 1-12, wherein the memory has memory cells that each stores more than one bit of data. 